[Python-Dev] Re: Re: PEP 318: Decorators last before colon

Terry Reedy tjreedy at udel.edu
Thu Apr 1 11:16:31 EST 2004


"Peter Norvig" <pnorvig at google.com> wrote in message
news:42B02151.420DCBB8 at mail.google.com...
> I have to say I favor the "last before colon" approach,

The way I see it today, we are trying to select syntax to define something
like a 'function metatype' (FMT) in order to get non-standard function-like
objects.  The idea and result strike me as similar (but *not* identical) to
running the pieces of a would-be class thru a metaclass.  If FMTs were
required to be defined and named before use, then [FMTidentifier] would be
analogous to __metaclass__ = MCidentifier after a class statement.  While a
metaclass can be defined in-place, over multiple lines, this does not work
nearly so well for an anonymous FMT.

(Has any consideration been given to an actual metafunc mechanism more
directly analogous to metaclasses, that would be given the *pieces* of a
would-be function (name, param names, default args, code body, etc), so
that there would not necessarily ever be a standard function object?)

> but if it has to be before the def, then I think it should have a
keyword,

Yes.  My support for 'as' was based on misremembering its quasi status.

> and if
> you don't want to introduce a new keyword, then it looks like "is" is
> the only reasonable candidate.  And if you do have a keyword, you
> don't need the square brackets.

Since the sequence is not going to be mutated, I would see them as a
positive distraction.

>  So you have
>
> is: classmethod
> def f(x):
>     pass
>
>
> is: author("Guido"), signature(int, result=None)
> def g(x):
>     pass

For this usage, 'is' is semantically better than 'as' anyway.

Terry J. Reedy






More information about the Python-Dev mailing list