Incorrect scope of list comprehension variables
steve at REMOVE-THIS-cybersource.com.au
Sun Apr 4 20:01:34 EDT 2010
On Sun, 04 Apr 2010 14:50:54 -0700, Paul Rubin wrote:
> Alain Ketterlin <alain at dpt-info.u-strasbg.fr> writes:
>> d[r] = [r for r in [4,5,6]]
>> THe problem is that the "r" in d[r] somehow captures the value of the
>> "r" in the list comprehension, and somehow kills the loop interator.
> Yes, this is a well known design error in Python 2.x. The 3.x series
> fixes this error but introduces other errors of its own.
Oh, do tell?
More information about the Python-list