![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How does Python class inherit objects?
In Python 2.x there are two styles of classes depending on the presence or absence of a built-in type as a base-class −
‘Old style’ or "Classic" style classes: they have no built-in type as a base class −
>>> class OldFoo: # no base class ... pass >>> OldFoo.__bases__ ()
"New" style classes: they have a built-in type as a base class meaning that, directly or indirectly, they have object as a base class −
>>> class NewFoo(object): # directly inherit from object ... pass >>> NewFoo.__bases__ (<type 'object'>,)
In Python 3.x however, only new style classes allowed that have built-in type as a base-class −
There is no need to mention object in parentheses after the class name here in class declaration. Here classes inherit from object implicitly.
>>> class Foo: # directly inherit from object ... pass >>> Foo.__bases__ (<type 'object'>,)
Advertisements