The article really has something against map and filter. Specifically:<p><pre><code> squares_under_10 = filter(lambda x: x < 10, map(lambda x: x*x, numbers))
squares_under_10 = [number*number for number in numbers if number*number < 10]
</code></pre>
Those two lines are functionally different; the second one (the one the article prefers) performs a costly multiplication twice.<p>I'm not saying list comprehensions are bad... I use them a ton. I just acknowledge that there are times where map and filter make a lot of sense. Even for trivial reasons like wrapping lines, using map allows you to break at commas instead of embedding backslashes in your code and trying to decide how it should all align.<p>If you haven't, check out the itertools standard library module. The power held in these functional, generator-based functions is amazing. Since I started using it, I don't know how many times I've used:<p><pre><code> imap(func, izip(somelist, repeat(somevalue)))
</code></pre>
and other such paradigms.<p>Hmm... more problems with the article:<p><pre><code> numbers = [1,10,100,1000,10000]
if [number for number in numbers if number < 10]:
print 'Success'
# Output: 'Success!'
</code></pre>
This is terrible. It may look nice all on one line, but it goes through the whole list when it doesn't need to. Better is:<p><pre><code> for number in numbers:
if number < 10:
print "Success"
break
</code></pre>
A problem with using the and ... or paradigm:<p><pre><code> result = test and 'Test is True' or 'Test is False'
</code></pre>
The page mentions that "Test is True" must evaluate to True or else it will always be skipped over even if test evaluates to True. It fails to mention, however that "Test is False" must also evaluate to True. Otherwise, if test evaluates to False, the entire expression returns False. Thus<p><pre><code> s = foo and "word: "+foo or ""
</code></pre>
will assign False to s instead of the desired "". In this case, it is quite clear that<p><pre><code> s = "word: "+foo if foo else ""
</code></pre>
is preferable.<p>I didn't find the article all that helpful, personally. It puts forward inefficient solutions as the recommended methods, and it doesn't offer much that I didn't already know. The two things that I learned, which I'm not sure that I'll ever use, are function decorators and the "string in substring" syntax.