A critic of Guido's blog on Python's lambda

Alex Martelli aleaxit at yahoo.com
Sun May 7 15:34:36 EDT 2006


Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:

> aleaxit at yahoo.com (Alex Martelli) writes:
> > I do hate it that
> >     [ x for x in container if predicate(x) ]
> > is an exact synonym of the more legible
> >     list( x for x in container if predicate(x) )
> 
> Heh, I hate it that it's NOT an exact synonym (the listcomp leaves 'x'
> polluting the namespace and clobbers any pre-existing 'x', but the
> gencomp makes a new temporary scope).

Yeah, that's gonna be fixed in 3.0 (can't be fixed before, as it would
break backwards compatibility) -- then we'll have useless synonyms.


> > and the proposed
> >     {1, 2, 3}
> > is an exact synonym of
> >     set((1, 2, 3))
> 
> There's one advantage that I can think of for the existing (and
> proposed) list/dict/set literals, which is that they are literals and
> can be treated as such by the parser.  Remember a while back that we
> had a discussion of reading expressions like
>   {'foo': (1,2,3),
>   'bar': 'file.txt'}
> from configuration files without using (unsafe) eval.  Aside from that

And as I recall I showed how to make a safe-eval -- that could easily be
built into 3.0, btw (including special treatment for builtin names of
types that are safe to construct). I'd be all in favor of specialcasing
such names in the parser, too, but that's a harder sell.

> I like the idea of using constructor functions instead of special syntax.

Problem is how to make _GvR_ like it too;-)


Alex



More information about the Python-list mailing list