1

I know the following works but i never understood what the difference are between

class Animal:

class Animal():

class Animal(object):

Is this just a style difference or something more to it?

1

1 Answer 1

2

In Python 3, all three are the same, i.e. all derive from object.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes this is the case in Python 3, but (very importantly) this is NOT the case in Python 2, where omitting the inheritance of object creates an old-style class. As a rule of thumb, always make new-style classes in Python 2.
@UlfAslak: yes sure! In Python 2 it was very important! As such python 3 if very nice!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.