#4668: wrap iterator returns in list() in functional howto.
This commit is contained in:
parent
abffe71dc1
commit
a3deea1312
|
@ -634,7 +634,7 @@ features of generator expressions:
|
||||||
... return s.upper()
|
... return s.upper()
|
||||||
|
|
||||||
|
|
||||||
>>> map(upper, ['sentence', 'fragment'])
|
>>> list(map(upper, ['sentence', 'fragment']))
|
||||||
['SENTENCE', 'FRAGMENT']
|
['SENTENCE', 'FRAGMENT']
|
||||||
>>> [upper(s) for s in ['sentence', 'fragment']]
|
>>> [upper(s) for s in ['sentence', 'fragment']]
|
||||||
['SENTENCE', 'FRAGMENT']
|
['SENTENCE', 'FRAGMENT']
|
||||||
|
@ -650,7 +650,7 @@ value.
|
||||||
>>> def is_even(x):
|
>>> def is_even(x):
|
||||||
... return (x % 2) == 0
|
... return (x % 2) == 0
|
||||||
|
|
||||||
>>> filter(is_even, range(10))
|
>>> list(filter(is_even, range(10)))
|
||||||
[0, 2, 4, 6, 8]
|
[0, 2, 4, 6, 8]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue