python object class

object class

object class is the default python, there are many ways, python species default list, str, dict and so are the inherited method object class

Inherited the object belongs to a class of new class that does not belong to inherit Classic

In python3 species are new default category, that is, all custom classes, the base class will inherit the object class

description

In a subclass of all classes are object of python3.x

So for some built-in methods will be written in object class

If you do not define a subclass, when the call finally calls the method object class

The program will not let unnecessary error occurred

__init__ method is an example wherein the

All inherited classes ---- object class new class

Not inherit the object class are in the classic class in python2

format

class A(object):
    pass    # 新式类

class A:
    pass   # 经典类 :在多继承中遵循深度优先
           # 经典类中没有super和mro方法

to sum up

All py3 the class inherits object is a new class

Follow the breadth-first algorithm C3 in succession

You can also use mro to see the order of succession

super This method can help us find the next class in order mro

Guess you like

Origin www.cnblogs.com/Hybb/p/11518961.html