Why inheritance from an object type

In one of my past questions, the responder tells me that it is better to inherit from an object when the class you want to create is like β€œfrom scratch” that you don't need to inherit from another class.

For example, as I always do:

class my_class: "a class inherits from nothing" def __init__(self): pass 

What did he or she suggest:

 class suggested_class(object): "a class inherits from object type" def __init__(self): pass 

I am confused by the advantages or disadvantages of both approaches.

Question 1:

So what is your idea, inherit from an object type or nothing?

+7
source share
1 answer

Inheritance from nothing creates an old-style class that relates differently to new-style classes. I don’t remember the specifics right now (see here for an explanation), but, as a rule, there is no reason to approve the old-style classes, so you should always inherit the object (if nothing is done).

+5
source

All Articles