[EMAIL PROTECTED] 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 ha
On 19 Nov 2005 07:06:30 -0800, [EMAIL PROTECTED] wrote:
>I've seen this construct in a script
>
[x.capitalize() for x in ['a','b', 'c']]
>['A', 'B', 'C']
>
>I tried another myself
>
[x+1 for x in [1,2,3]]
>[2, 3, 4]
>
>Apparently you can do
>[function(x) for x in list]
>
>I tried to
This type of construct seems to be called "list comprehension".
Googling for
Python "list comprehension"
gives a lot of hints that describe the construct.
--
http://mail.python.org/mailman/listinfo/python-list
I've seen this construct in a script
>>> [x.capitalize() for x in ['a','b', 'c']]
['A', 'B', 'C']
I tried another myself
>>> [x+1 for x in [1,2,3]]
[2, 3, 4]
>>>
Apparently you can do
[function(x) for x in list]
I tried to find a description of this in "Library Reference" but
couldn't find it.