New-style classes (was Re: Python 2.2 properties)
Stefan Schwarzer
s.schwarzer at ndh.net
Sun Jan 20 14:06:29 EST 2002
Hello Alex
Alex Martelli wrote:
> AFAIK, setting the module-global __metaclass__ is the way to
> do that. However, not the way you do it:
>
> >>> __metaclass__ = object
>
> This doesn't work because object is not designed as a metaclass:
[...]
> Rather:
>
> >>> __metaclass__ = type
> >>> class X: pass
> ...
> >>> x=X()
> >>>
>
> type is the metaclass you want to use here (and you can set the
> module-global __metaclass__ back to types.ClassType to go back
> to having classic classes by default).
Thank you very much for this clarification! :-)
Stefan
More information about the Python-list
mailing list