4 ms·
List comprehensions are extremely handy. I'm sure it's probably hard to come up with simple examples without using something that can be done better another wa
by pfranz 14y ago
List comprehensions are extremely handy. I'm sure it's probably hard to come up with simple examples without using something that can be done better another way, but the last few example could be done with map() and itertools.chain(). I'm surprised itertools isn't mentioned in the Python documentation he linked to.
- alwaysdoit 14y agoList comprehensions are actually preferred over map() because they are typically clearer. Guido at one point was actually planning to remove them from Python 3000. http://www.artima.com/weblogs/viewpost.jsp?thread=98196 http://www.artima.com/weblogs/viewpost.jsp?thread=98196 I do wish itertools.chain() was a built-in, however. So useful.