List comprehensions' ugliness

Eru ripolles at
Wed Feb 5 22:35:38 CET 2003

Hans Nowak <wurmy at> escribio:
> [...]
> I'm sure there are better (worse?) examples of list comp abuse.

Yeah, they can become quite obfuscated when used for the joy of 

m=max([(l.count(j),j,a.append(j)) for j in l if not j in a])[1]

That is very ugly code, and something that mus be avoided, but, hey it's
correct code; I mean that list comprehensions are great when used wisely,
but can make a hell out of a piece of code.

BTW, that code was just something I wrote while being jealous of the golf
perl contest :P 

Daniel Ripolles ( Eru )
There are only two things that smell like fish.
One of them is fish

More information about the Python-list mailing list