# What exactly is the difference between:

class Test:
    pass

# and

class Test2(object):
    pass
# 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

So practically there are interchangeable, right?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.