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

Alex Martelli aleaxit at yahoo.com
Tue Nov 4 03:24:13 EST 2003


On Tuesday 04 November 2003 02:09 am, Phillip J. Eby wrote:
   ...
> I'm not all that enthused about the metaclass usage, mainly because there's
> already an okay syntax (__metaclass__) for it.  I'd rather that class

Hmmm -- why is:

class Foo:
    __metaclass__ = MetaFoo
    ...

"ok", compared to e.g.:

class Foo is MetaFoo:
    ...

while, again for example,

    def foo():
        ...
     foo = staticmethod(foo)

is presumably deemed "not ok" compared to e.g.:

    def foo() is staticmethod:
        ...

???

Both cases of current syntax do the job (perhaps not elegantly but they do)
and in both cases a new syntax would increase elegance.

> decorators (if added) were decorators in the same way as function
> decorators.  Why?  Because I think that correct, combinable class
> decorators are probably easier for most people to write than correct,
> combinable metaclasses, and they are more easily combined than metaclasses
> are.

Combinable metaclasses may not be trivial to write, but with multiple 
inheritance it will often be feasible (except, presumably, when implied
layout or __new__ have conflicting requirements).  Of course, not having use 
cases of either custom metaclasses or class decorators in production use, the
discussion does risk being a bit abstract.  Did you have any specific use case 
in mind?


Alex




More information about the Python-Dev mailing list