Misuse of list comprehensions?
Diez B. Roggisch
deets at nospam.web.de
Tue May 20 10:36:20 EDT 2008
> That being said, I use that idiom myself. But I don't see anything wrong
> with using a list-comp as loop-abbreviation. because that is it's actual
> purpose. And also it is common in non-functional languages that l-values
> aren't always assigned, if the aren't needed. It's the consequence of
> having side-effects in a language - and python has them.
After being corrected about missing the construction of a None-containing
list, one needs of course to think about the waste of resources, as a
possible result-list is created in any case.
I personally still don't mind that (if we talk about a few hundred objects a
top) - but it makes a strong point against a general usage.
Diez
More information about the Python-list
mailing list