-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_class_methods.py
More file actions
28 lines (23 loc) · 1 KB
/
check_class_methods.py
File metadata and controls
28 lines (23 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class cls_methods:
"""" Demo of class methods regular, static and class methods """
def regular(self):
print(" checking regular method")
print("regular methods must and should have self as argument")
print("regular methods can be called from instantiated objects")
@staticmethod
def static_method():
print("checking static methods")
print("static methods are decorated with @staticmethod")
print("static methods can be called with class name")
print("static methods can be called with instantiated object name")
print("static methods does not take args or params")
@classmethod
def class_method(cls):
print("checking class methods")
print("class methods are decorated with @classmethod")
print("class methods can be called from class name")
print("class metohds can be called from instantiated object name")
cls1 = cls_methods()
cls1.regular()
cls_methods.static_method()
cls_methods.class_method()