While there are several articles written about new classes versus old classed I wasn't able to see a basic example with old/new style.
Asked
Active
Viewed 183 times
0
-
Note that old-style classes are gone in Python 3, so you shouldn't care too much. See also here: http://stackoverflow.com/questions/4015417/python-class-inherits-object and here: http://stackoverflow.com/questions/54867/old-style-and-new-style-classes-in-python – Cito Nov 03 '11 at 11:51
2 Answers
2
The only syntactic difference is that new style classes inherit from object:
class Old:
...
class New(object):
....

jro
- 9,300
- 2
- 32
- 37
0
I believe this wiki post is what you are looking for:
<snip>
The minor syntactic difference is that New Style Classes happen
to inherit from object.
class Old1:
...
class Old2(Old1, UserDict): # Assuming UserDict is still old-style
...
vs
class New1(object):
... class New2(New1):
... class New3(Old1, New2):
... class New4(dict, Old1): # dict is a newstyle class
<snip>

AlG
- 14,697
- 4
- 41
- 54
-
1`class New4` is particularly nasty in your example: it is a new style class, but instead of having `object` as the last class in the MRO, the MRO actually goes `New4, dict, object, Old1`. – Duncan Nov 03 '11 at 11:53
-
@Duncan I can't take credit for that example. It's directly copied from the linked Wiki page. I'll update my post to be clear. – AlG Nov 03 '11 at 11:56