The Python Oracle

Python 'object' type and inheritance

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Peaceful Mind

--

Chapters
00:00 Python 'Object' Type And Inheritance
00:32 Accepted Answer Score 9
00:58 Answer 2 Score 2
01:14 Answer 3 Score 2
01:26 Thank you

--

Full question
https://stackoverflow.com/questions/1540...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #inheritance #object

#avk47



ACCEPTED ANSWER

Score 9


Inheriting from object makes a class a "new-style class". There is a discussion of old-style vs. new-style here: What is the difference between old style and new style classes in Python?

As @CrazyJugglerDrummer commented below, in Python 3 all classes are "new-style" classes. In Python 3, the following two declarations are exactly equivalent:

class A(object):
    pass

class A:
    pass



ANSWER 2

Score 2


The first creates an "old-style" class, which are deprecated and have been removed in Python 3. You should not use it in Python 2.x. See the documentation for the Python data model.




ANSWER 3

Score 2


Old style and new style objects... they have sightly different behaviours, for example in the constructors, or in the method resolution order in multiple inheritance.