[New-bugs-announce] [issue4543] container constructors destroy argument

Kevin J. Woolley report at bugs.python.org
Fri Dec 5 08:53:40 CET 2008

New submission from Kevin J. Woolley <kjw at kjwcode.com>:

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)

Will correctly build a list from y and return [1, 3, 5] on the first
call to list(), but will return an empty list thereafter.  y still
identifies itself as a filter object, but you either can't coerce it to
anything else or the value of the filter object is reset (I don't know
how to tell the difference yet).

The other container constructors (set, tuple, etc.) seem to have the
same behaviour.

components: Library (Lib)
messages: 76975
nosy: kjwcode
severity: normal
status: open
title: container constructors destroy argument
type: behavior
versions: Python 3.0

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list