[Tutor] Re: a list comp
aon.912502367 at aon.at
aon.912502367 at aon.at
Thu Dec 11 05:11:53 EST 2003
----- Original von: RoT <RoT at 245t.com>:
> Basically you can observe this here:
>
> >>> newlist = []
> >>> print newlist.append(3)
> None
> >>> newlist
> [3]
> >>> print newlist.append(5)
> None
> >>> newlist
> [3, 5]
> >>> newlist = []
> >>> print [newlist.append(x) for x in 1,3,5]
> [None, None, None]
even though
newlist.append(x) returns None, the list comp 'does' evaluate to a new list doesn,t it
> >>> [index for index in del_list if index not in keep_list]
> [2, 4, 8]
so I still would have expected it to be returned.
It's shown in the above example: the list comprehension
returned [None, None, None] because each call of the
append-method returns None-
Gregor
-------------------------------------------
Versendet durch AonWebmail (webmail.aon.at)
More information about the Tutor
mailing list