Category Python

Static Method in Python

A method defined with an @staticmethod decorator in a class is called static method in Python. Similar to the class method, this method also belongs to a class rather than an instance of the class. Since a static method does…

Class Method in Python

When we define a method using @classmethod decorator inside a class, it is called class method in Python. This method is independent of any specific instance of the class. A class method is related to class rather than instances created…

Instance Method in Python

When we define a function inside a class definition, it is called instance method in Python. It belongs to a specific instance of a class, which is passed as the first argument in the method definition. By convention, this argument…

Static Variable in Python

Static variable in Python

When we define a variable inside a class definition, but outside any of class’s method definitions, it is called static variable in Python. In other words, a variable that is mutually shared by all the instances (objects) of a class…

What is Self in Python

Self parameter in Python

Self in Python is a reference to the current instance of the class itself (i.e. object created from the class). In Python, every object has an address. When we create an instance of a class, memory is allocated and data…