[Tutor] new book available
Rodrigues
op73418 at mail.telepac.pt
Tue Sep 9 13:11:20 EDT 2003
> -----Original Message-----
> From: tutor-bounces at python.org [mailto:tutor-bounces at python.org]On
> Behalf Of Alan Gauld
>
> > author's distinguishing "new" style class definitions
> > from "old" style ones.
> >
> > >>>class Test:
> >
> > >>>class Test (object):
> >
> > is the newer style. I don't think I've seen this point
> > discussed on PythonTutor or elsewhere. [Have I missed
> > something?]
>
> Yes, there's been a couple of discussions about new style
> classes. The fact that they inherit from 'object' (or
> a subclas of object) is indeed the distinguishing feature.
>
> ie
>
> >>> class Number(int):
>
> is also a new style class because int is a subclass of object...
>
It's also a new-style class if you set the metaclass, e.g.
>>> class Test:
... __metaclass__ = type
...
>>> Test.mro()
[<class '__main__.Test'>, <type 'object'>]
>>>
Best regards,
G. Rodrigues
More information about the Tutor
mailing list