[Python-Dev] Re: comprehension abbreviation (was: Adding any()
jcarlson at uci.edu
Tue Mar 29 19:21:12 CEST 2005
Steve Holden <steve at holdenweb.com> wrote:
> Having to write
> [x for x in seq]
> to produce a copy of a list doesn't seem that outrageous to me, and I
> don't find the predicate-less case of your proposal that convincing:
> [x in seq]
> seems somehow too terse.
And is already valid Python syntax; producing a list of a boolean (if x
is bound), a TypeError (if seq is a dictionary, x is bound, and x isn't
hashable), or a NameError (if x is not bound).
If I recall, changing the meaning of valid Python syntax is to be
frowned upon, and the suggestion should be tossed out the window
strictly because of that reason. As for "for x" or its equivalent,
being too much additional overhead to type in list comprehensions, I
think maybe we are getting too picky for our own good.
More information about the Python-Dev