List comprehension confusion...
Alex Martelli
aleax at aleax.it
Sun Feb 2 08:43:31 EST 2003
Afanasiy wrote:
> On Sun, 02 Feb 2003 03:10:27 GMT, Afanasiy <abelikov72 at hotmail.com> wrote:
>
>>I am confused about the purpose of list comprehensions.
>>What can they do which an explicit for loop cannot?
>
> Replies to this question relating to convenience led
> me to look for something like C's ternary ? operator.
>
> Does something like that exist in Python?
Several "something" are _somewhat_ "like that"...:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52310
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52282
All solutions in both entries and the many comments that
accompany them, reorganized and systematized and with
substantial discussion added, are in the printed version
of the Python Cookbook published by O'Reilly.
Alex
More information about the Python-list
mailing list