class A:
@staticmethod
def work():
print("works")
T = TypeVar('T', bound=A)
class B(Generic[T]):
@staticmethod
def execute():
T.work() # this doesn't work
# A.work() # but this would work
B[A].execute()
T.work()
doesn't work because T has no function work. Why doesn't it have? How can I change T to type from which I could run function work?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…