我有以下两门课A和B。如何使do_someting()方法调用B中的重写方法some_method()。这在Python中可行吗
class A:
@staticmethod
def some_method()
# pass
return
@classmethod
def do_something():
A.some_method()
...
return
class B(A):
@staticmethod
def some_method()
# how does do_something call here?
return
@classmethod
def run()
B.do_something()
return
这很简单,只要确保在
self
和cls
中修复冒号传递:如果您想从类B调用旧的
do_something
(类A中的那个),只需传入适当的类。B类:相关问题 更多 >
编程相关推荐