#4668: wrap iterator returns in list() in functional howto.

This commit is contained in:
Georg Brandl 2008-12-15 08:29:32 +00:00
parent abffe71dc1
commit a3deea1312
1 changed files with 2 additions and 2 deletions

View File

@ -634,7 +634,7 @@ features of generator expressions:
... return s.upper()
>>> map(upper, ['sentence', 'fragment'])
>>> list(map(upper, ['sentence', 'fragment']))
['SENTENCE', 'FRAGMENT']
>>> [upper(s) for s in ['sentence', 'fragment']]
['SENTENCE', 'FRAGMENT']
@ -650,7 +650,7 @@ value.
>>> def is_even(x):
... return (x % 2) == 0
>>> filter(is_even, range(10))
>>> list(filter(is_even, range(10)))
[0, 2, 4, 6, 8]