0

When creating child class, specify the super class as empty.

class Foo1():pass
class Foo2:pass

What is the different of Foo1 and Foo2.

And there are some other class definition.

class Foo3(object):
firelyu
  • 2,102
  • 5
  • 25
  • 29

1 Answers1

0

In Python 2, not specifying a parent class creates an old-style class. Explicitly inheriting from object creates a new-style class.

(There is no difference between class Foo and class Foo() that I know of. Both just result in an old-style class with no parent.)

In Python 3, all three syntaxes result in a new-style class; there's no difference.

See the following posts:

Community
  • 1
  • 1
user1686
  • 13,155
  • 2
  • 35
  • 54