- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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'>,)
- How to inherit a class in C#?
- How to create class objects in Python?
- PHP Inherit the properties of non-class object?
- How does class inheritance work in Python?
- How does nested character class subtraction work in Python?
- How does class variables function in multi-inheritance Python classes?
- How to inherit multiple interfaces in Java?
- Python program to define class for complex number objects
- How to access Python objects within objects in Python?
- How we can convert Python objects into JSON objects?
- How do you compare Python objects with .NET objects?
- What does built-in class attribute __dict__ do in Python?
- What does built-in class attribute __doc__ do in Python?
- What does built-in class attribute __name__ do in Python?
- What does built-in class attribute __module__ do in Python?