views:

28

answers:

1

Before py2.6 it's been answered here. http://stackoverflow.com/questions/332255/difference-between-class-foo-and-class-fooobject-in-python

But for python2.6+ and python3.x, is the first one wrong?

class Foo(): pass vs class Foo(object): pass

+1  A: 

For Python2.6+, before Python 3.0, the former creates an old-style class while the latter creates a new-style class. In Python 3.0, both create a new-style. The first isn't wrong, but for anything before 3.0 it has different semantics than the latter and is typically discouraged.

Michael Aaron Safyan