Please enable JavaScript.
Coggle requires JavaScript to display documents.
OOP - Coggle Diagram
OOP
Inheritance
Inheritance is a way of creating a new class for using details of an existing class without modifying it.
-
-
Since Python does support multiple inheritance, you can easily emulate the equivalence of interfaces
-
If an attribute is not found in the class itself, the search continues to the base class. This repeats recursively, if the base class is itself derived from other classes.
-
-
A class can be derived from more than one base class in Python, similar to C++. This is called multiple inheritance.
class MultiDerived(Base1, Base2):
In multilevel inheritance, features of the base class and the derived class are inherited into the new derived class.
his order is also called linearization of MultiDerived class and the set of rules used to find this order is called Method Resolution Order (MRO).
-
It refers to defining a new class with little or no modification to an existing class. The new class is called derived (or child) class and the one from which it inherits is called the base (or parent) class.
-
-
Objects and Classes
An object is simply a collection of data (variables) and methods (functions) that act on those data. Similarly, a class is a blueprint for that object.
-
-
For these reasons, the first argument of the function in class must be the object itself. This is conventionally called self.
init() function. This special function gets called whenever a new object of that class is instantiated.
Default to 0: def init(self, r=0, i=0):
-
Deleting attributes/objects with: del num1.imag, del c1
-