Raymond Hettinger <[EMAIL PROTECTED]> added the comment:
In Py3.0, the filter() builtin returns a consumable iterator, not a list.
It's a feature, not a bug ;-)
For the behavior you want, write:
y = list(filter(odd, x))
Or better yet, use a list comprehension:
y = [e for e in x if odd(e)]
S
New submission from Kevin J. Woolley <[EMAIL PROTECTED]>:
Doing the following (more info than necessary in case I'm doing
something weird):
def odd(n):
return n % 2
x = (1, 2, 3, 4, 5)
y = filter(odd, x)
list(y)
list(y)
Will correctly build a list from y and return [1, 3, 5] on the first
c