Path: blob/main/Pythod Codes_Numerical Computing/00-python-refresher.ipynb
69 views
Python Refresher
Very important: When trying to solve any problem, first see if you can do it with lists or dictionaries (dynamic arrays and maps). These will solve a majority of your problems.
OOP Concepts in Python
Creating a class with a constructor is simple with a minor difference: self
To access member variables and methods, you must always use self
. This is not optional as in other languages.
Composition
Composition is simple as always.
We can add methods to class even after it has been defined!
Inheritance
Inhertiance syntax is also slightly different but quite easy.
Access Parent Class' Overridden Methods
Polymorphism
You get that for free in Python. Just call the method. If it's overridden, the child class' method will be executed.
Access Modifiers
There are none. By convention, methods starting with _
are considered private and shouldn't be called from the outside. If you still want to do it, the response is, "good luck!".
See more details about classes on https://docs.python.org/3/tutorial/classes.html