Category: Tutorials
-
Dynamic Typing
One of the standout features of Python language is that it is a dynamically typed language. The compiler-based languages C/C++, Java, etc. are statically typed. Let us try to understand the difference between static typing and dynamic typing. In a statically typed language, each variable and its data type must be declared before assigning it a value.…
-
Dynamic Binding
In object-oriented programming, the concept of dynamic binding is closely related to polymorphism. In Python, dynamic binding is the process of resolving a method or attribute at runtime, instead of at compile time. According to the polymorphism feature, different objects respond differently to the same method call based on their implementations. This behavior is achieved through method overriding, where a subclass…
-
Method Overloading
Method overloading is a feature of object-oriented programming where a class can have multiple methods with the same name but different parameters. To overload method, we must change the number of parameters or the type of parameters, or both. Method Overloading in Python Unlike other programming languages like Java, C++, and C#, Python does not support…
-
Method Overriding
Method Overriding in Python The Python method overriding refers to defining a method in a subclass with the same name as a method in its superclass. In this case, the Python interpreter determines which method to call at runtime based on the actual object being referred to. You can always override your parent class methods. One reason…
-
Polymorphism
What is Polymorphism in Python? The term polymorphism refers to a function or method taking different forms in different contexts. Since Python is a dynamically typed language, polymorphism in Python is very easily implemented. If a method in a parent class is overridden with different business logic in its different child classes, the base class method is…
-
Inheritance
What is Inheritance in Python? Inheritance is one of the most important features of object-oriented programming languages like Python. It is used to inherit the properties and behaviours of one class to another. The class that inherits another class is called a child class and the class that gets inherited is called a base class or parent class. If…
-
Access Modifiers
The Python access modifiers are used to restrict access to class members (i.e., variables and methods) from outside the class. There are three types of access modifiers namely public, protected, and private. Usually, methods are defined as public and instance variable are private. This arrangement of private instance variables and public methods ensures implementation of principle of…
-
Constructors
Python constructor is an instance method in a class, that is automatically called whenever a new object of the class is created. The constructor’s role is to assign value to instance variables as soon as the object is declared. Python uses a special method called __init__() to initialize the instance variables for the object, as soon as it is…
-
Static Methods
What is Python Static Method? In Python, a static method is a type of method that does not require any instance to be called. It is very similar to the class method but the difference is that the static method doesn’t have a mandatory argument like reference to the object − self or reference to the class − cls. Static…
-
Class Methods
Methods belongs to an object of a class and used to perform specific operations. We can divide Python methods in three different categories, which are class method, instance method and static method. A Python class method is a method that is bound to the class and not to the instance of the class. It can be called on…