PEP 318 (was Re: [Python-Dev] Re: Guido's Magic Code was: inline sort option)

Alex Martelli aleaxit at
Fri Oct 31 02:59:40 EST 2003

On Thursday 30 October 2003 09:55 pm, Barry Warsaw wrote:
> On Thu, 2003-10-30 at 15:18, Guido van Rossum wrote:
> > > >   PEP 318 seems a ways off.
> > >
> > > Because of lack of consensus on syntax, or is it controversial in some
> > > other way?
> >
> > Both.  This is the kind of syntactic change that require much deep
> > thought before committing.  Unfortunately I don't have time for that
> > right now, so please don't ask.
> I won't, but I do hope this is something that we can settle for Python
> 2.4.  I've been using the functionality in Python 2.3 for a while now
> and it is wonderful, but I the tedium and clumsiness of the current
> syntax really puts a damper on its use.

Not on mine (my use), but, yes, I _have_ seen some Pythonistas be
rather perplexed by it.  Giving it a neat, cool look will be good.

BTW, when we do come around to PEP 318, I would suggest the 'as'
clause on a class statement as the best way to specify a metaclass.

'class Newstyle as type:' for example is IMHO neater -- and thus more
encouraging to the generalized use of newstyle classes -- than the
"inheriting from object" idea or the setting of __metaclass__; it reads
well AND makes what one's doing more obvious when a custom MC
is involved, because it's so "up-front".  Besides, it's STILL syntax for
a call to the thingy on the RHS of 'as', just like, say,
def foop() as staticmethod:
is, even though the details of how that call is performed are different
for metaclasses (called with classname/bases/classdict) and function
decorators (called with the function object).

BTW, the PEP isn't very clear about this, but, I would hope the 'as'
clause applies uniformly to ANY def or class statement, right?  No
reason to specialcase, that I can see -- "def ... as" may well be used
mostly inside classbodies, because we do have decorators ready for
that, but the 'synchronized(lock)' decorator used in the PEP's examples
would seem just as applicable to freestanding functions as to methods.


More information about the Python-Dev mailing list