#25 - (OOP) Instance method, Class method & Static method in Python

Опубликовано: 28 Март 2021
на канале: Tech Vitals
13,256
291

Learn about instance method, class method and static method in python class. Instance method is the most common method in python class and is also called as regular method. Instance method takes object i.e. 'self' as it's first parameter. Inside an instance method, we can access class & instance variables with self attribute.
Class method takes the class i.e. 'cls' as it's first parameter. We can use different name as well, but the convention is to use 'cls' to define a class parameter. Inside a class method, we can access class variables with class attribute. We have to use @classmethod decorator to define a class method.
Static method does not need to have an object or class as it's first parameter. We only include them in class because they have a logical connection. For the static method, there should be no use of class or instance variable.

Facebook:   / techvitals  


На этой странице сайта вы можете посмотреть видео онлайн #25 - (OOP) Instance method, Class method & Static method in Python длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Tech Vitals 28 Март 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 13,256 раз и оно понравилось 291 зрителям. Приятного просмотра!