[Python-ideas] Assignments in list/generator expressions
Eugene Toder
eltoder at gmail.com
Mon Apr 11 03:42:46 CEST 2011
On Sun, Apr 10, 2011 at 8:39 PM, Laura Creighton <lac at openend.se> wrote:
> The problem, as I see it is that you see it as ``missing''. You have
> some internal model of computer languages and not having it disagrees
> with your notion of 'completeness' or 'symmetry' or 'consistency' or
> something along those lines.
I just like to have a reasonable explanation for everything I see. A
good story is what often separates a feature from a bug.
On Sun, Apr 10, 2011 at 8:39 PM, Laura Creighton <lac at openend.se> wrote:
> There is real value in using whitespace and indentation to separate logical
> ideas, and jamming everything into a comprehension completely destroys this.
I don't think it's fair to judge a feature by trying to imagine the
worst misuse one can do with it. If you would do this consistently,
you'd never introduce arrays (think code using arrays instead of
classes, with magic undocumented indexes instead of attribute names)
or dynamically-typed scripting languages (think Perl).
Also, as pointed above, local assignment doesn't allow any more code
written as comprehension than one can write now -- there are multiple
work-arounds: repetition, nested comprehensions, for name in [expr].
Local assignment simply provides a more direct way of doing it, and to
me a more direct way is easier to read.
Eugene
More information about the Python-ideas
mailing list