[Python-3000] The 'make' statement PEP (was Re: Did I miss anything?)

Steven Bethard steven.bethard at gmail.com
Tue Apr 11 18:16:46 CEST 2006


On 4/11/06, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Steven Bethard wrote:
> > This is potentially a Python 2.6 PEP, but it has some optional
> > extensions for Python 3000 and may be relevant to the
> > adaptation/overloading/interfaces discussion.  It proposes a make
> > statement such that:
> >     make <callable> <name> <tuple>:
> >         <block>
> > would be translated into the assignment:
> >     <name> = <callable>("<name>", <tuple>, <namespace>)
> > much in the same way that the class statement works.  I've posted it
> > to comp.lang.python and had generally positive feedback.  I've
> > submitted it for a PEP number, but I haven't heard back yet:
> >
> > http://ucsu.colorado.edu/~bethard/py/pep_make_statement.txt
> > http://ucsu.colorado.edu/~bethard/py/pep_make_statement.html
>
> Pretty nice, but I think it would be even better if instead of focusing on the
> rare use case of a callable that needs to know the name it is being bound to,
> we looked at the more general idea of "use a trailing suite to define the
> keyword arguments to a function".

I started with something like that, and at the suggestion of folks
from the python-list tried to add some emphasis to the DRY part of it
too.  I think they're both important, and they're both a reason to
declare a class instead of calling type (and thus a reason to use the
make statement instead of calling the callable).

> And rather than a new keyword, I'd suggest permitting a "**" without a
> following expression to denote 'fill in these keyword arguments based on the
> following suite'.

I think this is a reasonable proposal too, but it's different enough
that I think it should have its own PEP.  Note that unless you really
change how metaclasses are called, this strongly breaks the parallel
between the new statement and class statements.  On the python-list at
least, people really didn't want to break that parallel.

> And to finish, an element tree example (based on the one on the front page of
> Effbot's overview, rather than the abbreviated one in the PEP). I think this
> example shows that requiring that an element's tag be the same as its name
> would in fact be a *bad* idea (how would you build the two paragraphs in the
> body?)

Yeah, this was brought up on the python-list:
    http://mail.python.org/pipermail/python-list/2006-April/335829.html
I've concluded that the best thing is to just pull the example (and
have done so).  I don't think you really want to use the make
statement for creating XML.

STeVe
--
Grammar am for people who can't think for myself.
        --- Bucky Katt, Get Fuzzy


More information about the Python-3000 mailing list