mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
Add take() to examples. Tighten the islice() example
This commit is contained in:
parent
5d2f515dd4
commit
3567a876c7
2 changed files with 11 additions and 2 deletions
|
|
@ -314,7 +314,7 @@ Check 1202 is for $823.14
|
|||
|
||||
>>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura',
|
||||
'', 'martin', '', 'walter', '', 'samuele']
|
||||
>>> for name in islice(reportlines, 3, len(reportlines), 2):
|
||||
>>> for name in islice(reportlines, 3, None, 2):
|
||||
... print name.title()
|
||||
...
|
||||
Alex
|
||||
|
|
@ -380,4 +380,7 @@ from building blocks.
|
|||
... result = result[1:] + (elem,)
|
||||
... yield result
|
||||
|
||||
>>> def take(n, seq):
|
||||
... return list(islice(seq, n))
|
||||
|
||||
\end{verbatim}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue