newbie-question about a list
mwm at mired.org
Sun Nov 20 05:24:46 CET 2005
bobueland at yahoo.com writes:
> I've seen this construct in a script
>>>> [x.capitalize() for x in ['a','b', 'c']]
> ['A', 'B', 'C']
> I tried to find a description of this in "Library Reference" but
> couldn't find it. Could somebody direct me where this type of construct
> is described.
As others have pointed out, it's called a "list comprehension". But
it's syntax, so the proper place to look for it is the "Language
Reference", not the "Library Reference". Except in this case, the
language reference is fairly opaque, so you're better off using the
google references others have already provided.
You might also look for the related construct, "generator
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list