[Python-ideas] More power in list comprehensions with the 'as' keyword
ntoronto at cs.byu.edu
Thu Aug 28 05:38:35 CEST 2008
Chris Rebert wrote:
> On Wed, Aug 27, 2008 at 4:17 PM, Terry Reedy <tjreedy at udel.edu> wrote:
>> To me, the drive to replace all for loops with list comps is mis-directed.
>> There is no end to the clauses people could propose to add: while, when,
>> whatever, until, unless. mapped_to, transformed_by, and so on. The result
>> would soon by something quite different from Python as we know it.
> Indeed, probably something approaching Common Lisp's overcomplicated
> "loop" macro:
> - Chris
Doesn't have to be that bad. I'd personally like a way to make a loop
expression that returns a list, with two operators that stuff new things
on and update old ones. That's most likely a reflection of my
expression-based-but-not-purely style, though.
One thing I've noticed in this discussion is that people seem to want
the "as" keyword to operate as a general expression-assignment operator.
Is that worth adding to the language? There would be no possibility of
getting it mixed up with "==", and the word as an infix operator is
sufficiently ugly that people would prefer "=" in general.
More information about the Python-ideas