# Topic covered
1. OOPs Concept
2. Class
3. Object
4. Four pillars of OOPs
* Encapsulation
* Data Abstraction
* Inheritance
* Polymorphism
5. Interface
6. Abstract class
7. Inner classes
8. Garbage Collection
[Read More]
OOPs | 02-Variables
Class and Instance variables
# Topic covered
1. Variables/Attribute
2. Instance/Regular Variables (Object Level Variables)
3. Static Variables (Class Level Variables)
4. Local variables (Method Level Variables)
5. Attribute Shawdowing
[Read More]
OOPs | 03-Methods
Regular, Class and Static methods
3. Methods in python
- Function
- Function is block of code that is also called by its name(
independent) - Function does not deal with Class and its instance concept.
- Function is block of code that is also called by its name(
- Methods
- Method is called by its name, but it is
associated to an object(dependent)
- Method is called by its name, but it is
The following are various types of allowed methods:
- Instance Methods - - self
- Class Methods - - cls
- Static Methods
OOPs | 04-Encapsulation
Access Modifier
4.1 Encapsulation in Python
- Access modifier are useful to attain encapsulation
- It is archived by access modifiers
public, private, protected
Python does not have strong distinctions between private and public variables like Java does.
There is no private-ness in python, as one of Python principles says –> We're all adults
# They just follow convention
Single underscore `_`
--> its suppose to be protected
Double underscore `__`
--> Do not use this field directly
# It is called Name Mangling
[Read More]
OOPs | 05-Inheritance
Inheritance
5. Inheritance
It is a mechanism that allows you to create a hierarchy of classes that share a set of properties and methods
by deriving a class from another class. Inheritance is the capability of one class to derive or inherit the properties from another class.
- It specifies that the child object acquires all the properties and behaviors of the parent object.
- It provides
re-usability of the code.
OOPs | 06-Magic Methods
Dunder, Magic, Special Methods
Magic Methods
Magic Methods are also known as Dunder methods, Special methods
Python dunder methods are the special predefined methods having two prefixes and two suffix underscores in the method name.
Here, the word dunder means double under (underscore).
These special dunder methods are used in case of operator overloading (they provide extended meaning beyond the predefined meaning to an operator).
[Read More]OOPs | 07-Property Decorators
Regular, Class and Static methods
Property Decorators
@property is a built-in decorator in python language which is used to make functions
like getters, setters, deleter in a class behave as class properties.
Make a method behaves as attribute/variable
OOPs | 08-Method Resolution order
Method Resolution order
Method Resolution order
- MRO
defines the orderin which the base classes are searched when executing a method. - First, the
method or attribute is searchedwithin a class and then it follows the order we specified while inheriting
3. Software Design | OOPs
Object oriented design
# Topic covered
* Classes, Objects
* Inheritance, Polymorphism
[Read More]