0

Possible Duplicate:
Old style and new style classes in Python
python class inherits object

What's the difference between

class foo: 

and

class foo(object):

Can anyone explain why we are using object in class definition?

Community
  • 1
  • 1

1 Answers1

0

In Python 2.x the first declaration is an old-style class and the second version is a new-style class. You should always use new-style classes for new code.

In Python 3 all classes are new-style so there is no difference.

Mark Byers
  • 811,555
  • 193
  • 1,581
  • 1,452