Browse Source

Context manager

pull/41/head
Jure Šorn 5 years ago
parent
commit
b2fdaa79e8
2 changed files with 4 additions and 4 deletions
  1. 4
      README.md
  2. 4
      index.html

4
README.md

@ -1167,8 +1167,8 @@ Hello World!
#### List of existing context managers: #### List of existing context managers:
```python ```python
with open('<path>', ...) as file: ...
with wave.open('<path>', ...) as wave_file: ...
with open('<path>') as file: ...
with wave.open('<path>') as wave_file: ...
with memoryview(<bytes/bytearray/array>) as view: ... with memoryview(<bytes/bytearray/array>) as view: ...
db = sqlite3.connect('<path>'); with db: db.execute('<insert_query>') db = sqlite3.connect('<path>'); with db: db.execute('<insert_query>')
lock = threading.RLock(); with lock: ... lock = threading.RLock(); with lock: ...

4
index.html

@ -1095,8 +1095,8 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
<span class="hljs-meta">... </span> print(file.read()) <span class="hljs-meta">... </span> print(file.read())
Hello World! Hello World!
</code></pre> </code></pre>
<div><h4 id="listofexistingcontextmanagers">List of existing context managers:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">with</span> open(<span class="hljs-string">'&lt;path&gt;'</span>, ...) <span class="hljs-keyword">as</span> file: ...
<span class="hljs-keyword">with</span> wave.open(<span class="hljs-string">'&lt;path&gt;'</span>, ...) <span class="hljs-keyword">as</span> wave_file: ...
<div><h4 id="listofexistingcontextmanagers">List of existing context managers:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">with</span> open(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-keyword">as</span> file: ...
<span class="hljs-keyword">with</span> wave.open(<span class="hljs-string">'&lt;path&gt;'</span>) <span class="hljs-keyword">as</span> wave_file: ...
<span class="hljs-keyword">with</span> memoryview(&lt;bytes/bytearray/array&gt;) <span class="hljs-keyword">as</span> view: ... <span class="hljs-keyword">with</span> memoryview(&lt;bytes/bytearray/array&gt;) <span class="hljs-keyword">as</span> view: ...
db = sqlite3.connect(<span class="hljs-string">'&lt;path&gt;'</span>); <span class="hljs-keyword">with</span> db: db.execute(<span class="hljs-string">'&lt;insert_query&gt;'</span>) db = sqlite3.connect(<span class="hljs-string">'&lt;path&gt;'</span>); <span class="hljs-keyword">with</span> db: db.execute(<span class="hljs-string">'&lt;insert_query&gt;'</span>)
lock = threading.RLock(); <span class="hljs-keyword">with</span> lock: ... lock = threading.RLock(); <span class="hljs-keyword">with</span> lock: ...

Loading…
Cancel
Save