Skip to content

Commit 5e80ed3

Browse files
committed
fix: ABC and ABCMeta usecase and abc module decorator.
1 parent 9f6149d commit 5e80ed3

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import abc
2+
from abc import abstractmethod
3+
4+
class TestClassMethodDecorator():
5+
@staticmethod
6+
def method_static_method():
7+
print("In static method")
8+
9+
@classmethod
10+
def method_class_method(cls):
11+
print("In class method")
12+
13+
@abstractmethod
14+
def method_abstract(self):
15+
print("In abstract method")
16+
17+
@staticmethod
18+
@abstractmethod
19+
def method_abstract_static():
20+
print("In abstract static method")
21+
22+
def invoke_method_static_method_in_class(self):
23+
"""
24+
Q: why can't we do this?
25+
"""
26+
method_static_method()
27+
28+
29+
if __name__ == "__main__":
30+
print(f"Test: {TestClassMethodDecorator.__name__}")
31+
a = TestClassMethodDecorator()
32+
a.method_static_method()
33+
TestClassMethodDecorator.method_static_method()
34+
# a.invoke_method_static_method_in_class()
35+
36+
a.method_abstract()
37+
# TestClassMethodDecorator.method_abstract()
38+
TestClassMethodDecorator.method_abstract_static()
39+
40+
a.method_class_method()
41+
TestClassMethodDecorator.method_class_method()
42+
43+
print(abc.get_cache_token())
44+
print(type(abc.get_cache_token()))

0 commit comments

Comments
 (0)