Python is Considered Harmful
mike420 at ziplip.com
mike420 at ziplip.com
Mon Oct 27 01:25:41 EST 2003
Ladies and Gentlemen,
I present to you the final and ultimate proof of Python's
brain-damage:
As you may remember,
flist = []
for i in range(3)
f = lambda x: x + i
flist.append(f)
[f(1) for f in flist]
produces [3, 3, 3] in Python.
In Haskell, we would express this as follows:
map (\f -> f 1) [\x -> x + i | i <- [0..2]]
This, of course, evaluates to the expected [1, 2, 3]
As you might have heard, the ever so generous GvR allowed us write
the same in Python (literal translation, really):
map(lambda f: f(1), [lambda x: x + 1 for i in range(3)])
What do you think this evaluates to: also [1, 2, 3] or [3, 3, 3]
as before?
Guess again, it's [2, 2, 2] !
ROTFLMFAO!
Pythonista, you are all very welcome to learn Haskell.
You will find the syntax very familiar. Haskell is short
too (compare one line above that gives the correct
result to several Python lines that surprise you)
All this Python bashing is starting to feel like mocking
a retarded child...
420
More information about the Python-list
mailing list