Video Link : https://www.youtube.com/watch?v=EiOglTERPEo
Main Takes:
1. super() function in Python is different from other OOP languages. Because it calls the next one in line NOT the ancestors (in context of Inheritance).
2. The next one in line is identified from MRO as below,
3. Catch No.1 -> Every (in between) Ancestor must have implemented "super()". If not use subclass while inheriting.
Eg. https://stackoverflow.com/questions/13380819/multiple-inheritance-along-with-threading-in-python
4. Catch No.2 -> Who is upstream (or next in line) is determined by the derived class. So to stop the call chain a root class without super() is required.
5. Catch No.3 -> All class constructors must have implemented named parameters (**kwargs).
6. Class with most reusable code must be parent. (Other consideration must take back step)
No comments:
Post a Comment