[Python-ideas] More power in list comprehensions with the 'as' keyword

Josiah Carlson josiah.carlson at gmail.com
Thu Aug 28 18:59:38 CEST 2008


That's just as bad as the original.  Please stop offering new syntax.

 - Josiah

On Thu, Aug 28, 2008 at 9:20 AM, Mathias Panzenböck
<grosser.meister.morti at gmx.net> wrote:
> Marcin 'Qrczak' Kowalczyk schrieb:
>> 2008/8/28 Cesare Di Mauro <cesare.dimauro at a-tono.com>:
>>
>>> A solution could be this:
>>>
>>> [stripped for l in text.split('\n') with l.strip() as stripped if stripped != '']
>>>
>>> so that you can keep both values (l and l.strip()) too.
>>
>> In Haskell this would be (I translate only the list comprehension
>> structure, leaving expressions in Python syntax):
>>
>> [stripped | l <- text.split('\n'), let stripped = l.strip(), stripped != '']
>>
>> Python borrowed 2 out of 3 kinds of list comprehension constructs.
>>
>
> so maybe?
>
> [stripped for l in text.split('\n') if stripped != '' let stripped = l.strip()]
>
> but this would introduce a new keyword.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



More information about the Python-ideas mailing list