a small problem
knotwell at my-deja.com
knotwell at my-deja.com
Tue Jan 11 19:06:50 EST 2000
Hello all--
Is the following a bug?
>>> q = [(1,'dd'),(2,'ddd'),(3,'ddddd')]
>>> reduce(lambda x,y: x[0] + y[0],q)
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "<stdin>", line 1, in <lambda>
AttributeError: __getitem__
Meanwhile, map(lambda x: x[0],q) --> [0,1,2] as one would expect.
Similarly, filter appears to work as well. If this isn't a bug, why
should reduce behave differently than filter and map?
Thanks.
--Brad
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list