[Python-ideas] Tuple Comprehensions

Sven Marnach sven at marnach.net
Sun Oct 9 23:06:32 CEST 2011


Karthick Sankarachary schrieb am So, 09. Okt 2011, um 13:57:16 -0700:
>  >>> (weapon.strip() for weapon in freshfruit)
>  ('banana', 'loganberry', 'passion fruit')

This syntax is already taken for generator expressions.  You can
construct a tuple from the generator expression using

    tuple(weapon.strip() for weapon in freshfruit)

Cheers,
    Sven



More information about the Python-ideas mailing list