[Python-Dev] Re: accumulator display syntax

Raymond Hettinger python at rcn.com
Tue Oct 21 23:17:26 EDT 2003


>  Neil Schemenauer <nas-python at python.ca> wrote:
> > nother nice thing is that we have tuple and dict comprehensions
> > for free:
> >
> >   tuple(x for x in S)
> >   dict((k, v) for k, v in S)
> >   Set(x for x in S)

[David Eppstein]
> Who cares about tuple comprehensions, but I would like similar
syntactic
> sugar for dict comprehensions as for lists:
>     {k:v for k,v in S}
> (PEP 274).

-1

Let's keep just one way to do it.

That constuct saves a few characters just to get a little 
cuteness and another special case to remember and maintain.

Once you have iterator expressions, you've already gotten 99% of
the benefits of PEP 274.

List comprehensions, on the other hand, already exist, so they
*have* to be supported.


Raymond




More information about the Python-Dev mailing list