was: Re: looking for MOP documentation

Peter Hansen peter at engcorp.com
Fri Sep 19 07:21:58 EDT 2003


Christian Tanzer wrote:
> 
> Peter Hansen <peter at engcorp.com> wrote:
> > But it doesn't really modify the *language's* behaviour in the way
> > implied by a simplistic reading of the above phrase.  That is, the
> > "obvious" interpretation is that syntax and grammar are being affected,
> > not just the behaviour of one small slice of the language, specifically
> > how classes behave.  In some languages the two things are not so
> > separate, but in Python they seem to be.
> 
> Are you sure?
> 
> >>> class Nasty(type) :
> ...   def __new__(cls,name,bases,d):
> ...     return 1
> ...
> >>> class Surprise(object):
> ...   __metaclass__ = Nasty
> ...
> >>> Surprise
> 1
> >>> type(_)
> <type 'int'>
> >>>

I don't see how that changes the syntax or grammar of the language.
You're just playing with types.

-Peter




More information about the Python-list mailing list