[Python-ideas] Assignments in list/generator expressions

Laura Creighton lac at openend.se
Sun Apr 10 17:13:18 CEST 2011


In a message of Sun, 10 Apr 2011 09:31:53 EDT, Eugene Toder writes:
>> It isn't strangely missing at all, it's just hard:
>> http://www.python.org/dev/peps/pep-3150/
>
>Local definition in list comprehension is significantly simpler that
>'given'. Semantically, 'with name = expr' can be treated as a more
>readable form of 'for name in [expr]'. Implementation can use a simple
>assignment.
>
>Eugene

We'll have to disagree then.  I think 'for name in [expr]' is a whole
lot more readable than 'with name = expr'.  Indeed, my recent
experience in code reading had shown, I thought, that a good number of
people are using the with statement whenever they possibly can, to the
detriment of readability.

Comments like this make me wonder if the problem is that those people
actually find those constructs more readable.  If we largely cannot
agree on what makes for more readable code, then I think we have a
different problem than the one I thought we had (people showing off
their knowledge of how to use every new feature).

Laura




More information about the Python-ideas mailing list