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):
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):
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: