New-style classes (was Re: Python 2.2 properties)
Stefan Schwarzer
s.schwarzer at ndh.net
Sun Jan 20 08:49:12 EST 2002
As a related topic:
Thomas Heller wrote:
> You must derive your class from object:
> > >>> class foo(object):
I just wondered if there is something like
from __future__ import new_style_classes
to get the derivation from object by default if no base class is
specified.
>From http://python.sourceforge.net/peps/pep-0253.html it seems that this
can be accomplished by setting __metaclass__ at the module level:
Python 2.2 (#0, Dec 24 2001, 18:42:48) [EMX GCC 2.8.1] on os2emx
Type "help", "copyright", "credits" or "license" for more information.
>>> class X:
... pass
...
>>> type(X)
<type 'class'>
vs.
Python 2.2 (#0, Dec 24 2001, 18:42:48) [EMX GCC 2.8.1] on os2emx
Type "help", "copyright", "credits" or "license" for more information.
>>> __metaclass__ = object
>>> class X:
... pass
...
>>> type(X)
<type 'object'>
Stefan
More information about the Python-list
mailing list