42 - Python class and static methods

preview_player
Показать описание
#python #python3 #pythoncourse #classandstaticmethods

@kingoftechniques6864

Class method vs static method in Python. The class method in Python is a method, which is bound to the class but not the object of that class. The static methods are also same but there are some basic differences. For class methods, we need to specify @classmethod decorator, and for static method @staticmethod decorator is used.

A class method can access or modify class state while a static method can’t access or modify it. In general, static methods know nothing about class state. They are utility type methods that take some parameters and work upon those parameters. On the other hand class methods must have class as parameter. We use @classmethod decorator in python

Create staticmethod using the @staticmethod decorator and staticmethod () function A static method is a general utility method that performs a task in isolation. Static methods in Python are similar to those found in Java or C++ A static method is bound to the class and not the object of the class.
Рекомендации по теме
Комментарии
Автор

Great lessons and so good for my understanding

jugijoung