0

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.

sorin
  • 137,198
  • 150
  • 472
  • 707
  • 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 Answers2

2

The only syntactic difference is that new style classes inherit from object:

class Old:
    ...

class New(object):
    ....
jro
  • 8,540
  • 27
  • 33
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
  • 13,325
  • 4
  • 39
  • 50
  • 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