In one of my past questions, a answerer suggests me that it is better to inherit from object when the class you want to create is like from scratch, which is no need to inherit from other class.
For example, like what I always do:
class my_class:
"a class inherits from nothing"
def __init__(self):
pass
For what he or she suggested:
class suggested_class(object):
"a class inherits from object type"
def __init__(self):
pass
I am confused with the benefits or disadvantage from both approaches.
Question 1:
So what is your idea, inherit from object type or nothing?
Inheriting from nothing creates an old-style class, which has different behaviour to new-style classes. I don't remember the specifics just now (see here for an explanation), but as a general rule, there's no reason to favour old-style classes, so you should always inherit from object (if nothing else).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With