Browse Source

Duck types

pull/52/merge
Jure Šorn 4 years ago
parent
commit
aaace2610c
2 changed files with 2 additions and 2 deletions
  1. 2
      README.md
  2. 2
      index.html

2
README.md

@ -1175,7 +1175,7 @@ class Counter:
* **Any exception that happens inside the with block is passed to the exit() method.**
* **If it wishes to suppress the exception it must return a true value.**
```python
class MyOpen():
class MyOpen:
def __init__(self, filename):
self.filename = filename
def __enter__(self):

2
index.html

@ -1120,7 +1120,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
<li><strong>Exit() should release the resources.</strong></li>
<li><strong>Any exception that happens inside the with block is passed to the exit() method.</strong></li>
<li><strong>If it wishes to suppress the exception it must return a true value.</strong> </li>
</ul><pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyOpen</span><span class="hljs-params">()</span>:</span>
</ul><pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyOpen</span>:</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, filename)</span>:</span>
self.filename = filename
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__enter__</span><span class="hljs-params">(self)</span>:</span>

Loading…
Cancel
Save