Python is not [yet] Considered Harmful

Hannu Kankaanp?? hanzspam at yahoo.com.au
Mon Oct 27 08:26:52 EST 2003


mike420 at ziplip.com wrote in message news:<F5PTFQP4LSMMFZJQOCN2KCOHLUACIBHXMMEJCJEO at ziplip.com>...
> It was an honest mistake, not a troll! Still, I think it should
> be [1, 2, 3] instead of [3, 3, 3]

I don't think you understand what a troll is. Troll is someone
who posts any of the following:

1. "Python is Considered Harmful" (given it's highly readable syntax,
great libraries and high dynamicity, I can't see how a single
feature could make Python 'harmful'. The title could've just been
"Unexpected behaviour of closures inside list comprehensions")

2. "I present to you the final and ultimate proof of Python's
brain-damage" (again, a needless attack.. which turned against
yourself though)

3. "All this Python bashing is starting to feel like mocking
a retarded child..." (this doesn't need explanation, I hope)

And look, you posted all three of them in a single message!
Well, your typo gave us a good laugh nevertheless ;)

If you want [1, 2, 3], try:

map(lambda f: f(1), [lambda x, i=i: x + i for i in range(3)])

i=i will make a local variable i within the lambda so that
each lambda will refer to their own i instead of sharing the
same i from the outer scope.




More information about the Python-list mailing list