Browse Source

Duck types

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

4
README.md

@ -1146,7 +1146,7 @@ class Counter:
``` ```
#### Python has many different iterator objects: #### Python has many different iterator objects:
* **Objects returned by the [iter()](#iterator) function, such as list\_iterator and set\_iterator.**
* **Iterators returned by the [iter()](#iterator) function, such as list\_iterator and set\_iterator.**
* **Objects returned by the [itertools](#itertools) module, such as count, repeat and cycle.** * **Objects returned by the [itertools](#itertools) module, such as count, repeat and cycle.**
* **Generators returned by the [generator functions](#generator) and [generator expressions](#comprehension).** * **Generators returned by the [generator functions](#generator) and [generator expressions](#comprehension).**
* **File objects returned by the [open()](#open) function, etc.** * **File objects returned by the [open()](#open) function, etc.**
@ -1170,7 +1170,7 @@ class Counter:
``` ```
### Context Manager ### Context Manager
* **Enter() should lock the resources and (optionally) return an object.**
* **Enter() should lock the resources and optionally return an object.**
* **Exit() should release the resources.** * **Exit() should release the resources.**
* **Any exception that happens inside the with block is passed to the exit() method.** * **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.** * **If it wishes to suppress the exception it must return a true value.**

4
index.html

@ -1093,7 +1093,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>) (<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
</code></pre> </code></pre>
<div><h4 id="pythonhasmanydifferentiteratorobjects">Python has many different iterator objects:</h4><ul> <div><h4 id="pythonhasmanydifferentiteratorobjects">Python has many different iterator objects:</h4><ul>
<li><strong>Objects returned by the <a href="#iterator">iter()</a> function, such as list_iterator and set_iterator.</strong></li>
<li><strong>Iterators returned by the <a href="#iterator">iter()</a> function, such as list_iterator and set_iterator.</strong></li>
<li><strong>Objects returned by the <a href="#itertools">itertools</a> module, such as count, repeat and cycle.</strong></li> <li><strong>Objects returned by the <a href="#itertools">itertools</a> module, such as count, repeat and cycle.</strong></li>
<li><strong>Generators returned by the <a href="#generator">generator functions</a> and <a href="#comprehension">generator expressions</a>.</strong></li> <li><strong>Generators returned by the <a href="#generator">generator functions</a> and <a href="#comprehension">generator expressions</a>.</strong></li>
<li><strong>File objects returned by the <a href="#open">open()</a> function, etc.</strong></li> <li><strong>File objects returned by the <a href="#open">open()</a> function, etc.</strong></li>
@ -1116,7 +1116,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>) (<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>)
</code></pre> </code></pre>
<div><h3 id="contextmanager">Context Manager</h3><ul> <div><h3 id="contextmanager">Context Manager</h3><ul>
<li><strong>Enter() should lock the resources and (optionally) return an object.</strong></li>
<li><strong>Enter() should lock the resources and optionally return an object.</strong></li>
<li><strong>Exit() should release the resources.</strong></li> <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>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> <li><strong>If it wishes to suppress the exception it must return a true value.</strong> </li>

Loading…
Cancel
Save