When creating a class in python should it inherit from object or Object, or neither?
Is there any need to inherit from object at all?
class NewClass(object)
or
class NewClass(Object)
or
class NewClass()
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A class inherits from
objectif it is a ‘new style’ object. It was a feature introduced in python2.2.New style objects have a different object model to classic objects, and some things won’t work properly with old style objects, for instance,
super(),@property, and descriptors. See this article for a good description of what a new style class is:Python Documentation – Type and Class Changes
Object, on the other hand, seems to be a poorly named variable or object.