2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by vegaseat
0
# What exactly is the difference between:

class Test:
    pass

# and

class Test2(object):
    pass

If you use Python3 there is no difference other than the name of the class. That means class Test will automatically inherit objects.

In Python2 you can use for instance __slots__ to restrict class variable creation outside the 'new type' class Test2

0

So practically there are interchangeable, right?

If you use Python3
class Test2(object):
can simply be written
class Test2:
since Python3 will add the object inheritance internally anyway.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.