|
|
@ -1034,6 +1034,10 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas |
|
|
|
<span class="hljs-keyword">return</span> <span class="hljs-built_in">NotImplemented</span> |
|
|
|
</code></pre> |
|
|
|
<h3 id="iterator-1">Iterator</h3> |
|
|
|
<ul> |
|
|
|
<li><strong>Next() should return next item or raise 'StopIteration'.</strong></li> |
|
|
|
<li><strong>Iter() should return 'self'.</strong></li> |
|
|
|
</ul> |
|
|
|
<pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Counter</span>:</span> |
|
|
|
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self)</span>:</span> |
|
|
|
self.i = <span class="hljs-number">0</span> |
|
|
@ -1120,7 +1124,7 @@ lock = threading.RLock(); <span class="hljs-keyword">with</span> lock: ... |
|
|
|
</code></pre> |
|
|
|
<h3 id="sequence">Sequence</h3> |
|
|
|
<ul> |
|
|
|
<li><strong>Only required methods are len() and getitem().</strong></li> |
|
|
|
<li><strong>Only required methods are len() and getitem(), that should return an item at index or raise 'IndexError'.</strong></li> |
|
|
|
<li><strong>Iter() and contains() automatically work on any object that has getitem() defined.</strong></li> |
|
|
|
<li><strong>Reversed() automatically works on any object that has getitem() and len() defined.</strong></li> |
|
|
|
</ul> |
|
|
|