[Python-ideas] Statements vs Expressions... why?
Arnaud Delobelle
arnodel at googlemail.com
Sun Sep 14 20:28:41 CEST 2008
On 14 Sep 2008, at 10:25, Cliff Wells wrote:
>> Now say you want to write that inline with a for-expression:
>>
>> '-'.join(
>> for J in I:
>> for j in J:
>> YIELD j
>> )
>>
>> That won't work because the j's will be accumulated in the inner loop
>> and the outer loop won't accumulate anything, therefore returning an
>> empty iterable.
>
> How about this way instead (since for-loop is now an expression):
>
> '-'.join(
> for j in ( for J in I: YIELD J ): YIELD j
> )
After you've had a good night's sleep and when you look at this again,
you'll definitely think that you were too hasty in replying :)
--
Arnaud
More information about the Python-ideas
mailing list