Inherting from object. Or not.
mefjr75 at hotmail.com
Wed Jan 26 22:24:41 CET 2005
What you are seeing is a step on the path to unification of types and
Now we have that clear ;)
Classes that inherit from object are 'new style classes'.
They were introduced in 2.2 and they have different internal methods.
The ones that have no declaration is an 'old style class'.
That link may be help.
It is not required to write a class as 'class myclass(object)' yet, so
many don't. In some cases it will matter which you use. In others cases
Be sure to try this an an interpreter promt:
Py> class NewKlass(object):
Py> class OldKlass:
Py> new = NewKlass()
Py> old = OldKlass()
Py> print dir(new)
Py> print dir(old)
Also new style classes are faster.
Frans Englich wrote:
> (Picking up a side track of the "python without OO" thread.)
> On Wednesday 26 January 2005 11:01, Neil Benn wrote:
> > I say this because you do need to be aware of the
> > 'mythical python wand' which will turn you from a bad programmer
> > good programmer simply by typing 'class Klass(object):'.
> What is the difference between inherting form object, and not doing
> what's the difference between the two following classes?
> class foo:
> class bar(object):
> Sometimes people inherit from it, and sometimes not. I don't see a
> their choices.
More information about the Python-list