Skip to content

Commit e3472c2

Browse files
committed
Generator
1 parent f3157fe commit e3472c2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ from itertools import count, repeat, cycle, chain, islice
218218

219219
Generator
220220
---------
221-
**Convenient way to implement the iterator protocol.**
221+
* **Convenient way to implement the iterator protocol.**
222+
* **Any function that contains a yield statement returns a generator object.**
223+
* **Generators and iterators are interchangeable.**
222224

223225
```python
224226
def count(start, step):

index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,11 @@ <h3 id="itertools">Itertools</h3>
346346
&lt;iter&gt; = islice(&lt;collection&gt;, from_inclusive, to_exclusive, +step_size)
347347
</code></pre>
348348
<h2 id="generator"><a href="#generator" name="generator">#</a>Generator</h2>
349-
<p><strong>Convenient way to implement the iterator protocol.</strong></p>
349+
<ul>
350+
<li><strong>Convenient way to implement the iterator protocol.</strong></li>
351+
<li><strong>Any function that contains a yield statement returns a generator object.</strong></li>
352+
<li><strong>Generators and iterators are interchangeable.</strong></li>
353+
</ul>
350354
<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>
351355
<span class="hljs-keyword">while</span> <span class="hljs-keyword">True</span>:
352356
<span class="hljs-keyword">yield</span> start

0 commit comments

Comments
 (0)