PEP 312 - Making lambdas implicit worries me, surely it's just the name 'lambda' that is bad...

Stephen Horne intentionally at blank.co.uk
Tue Mar 4 02:06:22 EST 2003


On Mon, 03 Mar 2003 17:16:55 -0800, Erik Max Francis <max at alcyone.com>
wrote:

>Alexander Schmolck wrote:
>
>> It isn't a major problem, but I can remember that it did
>> (infrequently) cause
>> me bugs, so it's not all theoretical. Another minor cause of annoyance
>> are
>> things like this:
>> 
>>   SOME_GLOBAL_CONST = [(y**2, x**2) for (x,y) in
>>      SOME_OTHER_GLOBAL_CONST]
>>   del x, y # I could do without this
>
>But that wouldn't be any different than the explicit for loop form:
>
>	SOME_GLOBAL_CONST = []
>	for x, y in SOME_OTHER_GLOBAL_CONST:
>	    SOME_GLOBAL_CONST.append((y**2, x**2))
>	del x, y # you could do without this

To me, the slight difference is that because I see list comprehensions
as functional I don't expect them to have side effects. Of course it
is a trivial issue, but it isn't *quite* as benign as the for loop
(which is 'supposed to' have side effects).

-- 
steve at ninereeds dot fsnet dot co dot uk




More information about the Python-list mailing list