When is List Comprehension inappropriate?

Alex Martelli aleax at mac.com
Tue Mar 20 07:25:40 CET 2007

BJörn Lindqvist <bjourne at gmail.com> wrote:
> even2 = [(pos, col) for pos, col in iterimage(im, width, height, 2)]

list(iterimage(etc etc))

is surely a better way to express identical semantics.  More generally,
[x for x in whatever] (whether x is a single name or gets peculiarly
unpacked and repacked like here) is a good example of inappropriate LC,
to get back to the question in the subject: list(whatever) is the "one
obvious way" to perform the same task.


More information about the Python-list mailing list