Browse Source

Generator

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

4
README.md

@ -218,7 +218,9 @@ from itertools import count, repeat, cycle, chain, islice
Generator
---------
**Convenient way to implement the iterator protocol.**
* **Convenient way to implement the iterator protocol.**
* **Any function that contains a yield statement returns a generator object.**
* **Generators and iterators are interchangeable.**
```python
def count(start, step):

6
index.html

@ -346,7 +346,11 @@ to_exclusive = <range>.stop
<iter> = islice(<collection>, from_inclusive, to_exclusive, +step_size)
</code></pre>
<h2 id="generator"><a href="#generator" name="generator">#</a>Generator</h2>
<p><strong>Convenient way to implement the iterator protocol.</strong></p>
<ul>
<li><strong>Convenient way to implement the iterator protocol.</strong></li>
<li><strong>Any function that contains a yield statement returns a generator object.</strong></li>
<li><strong>Generators and iterators are interchangeable.</strong></li>
</ul>
<pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">count</span><span class="hljs-params">(start, step)</span>:</span>
<span class="hljs-keyword">while</span> <span class="hljs-keyword">True</span>:
<span class="hljs-keyword">yield</span> start

Loading…
Cancel
Save