【发布时间】:2018-11-01 15:54:03
【问题描述】:
我有一个名为A 的类,有两个子类B 和C。以下内容有意义吗?还是有更好的办法?
class A():
...
def do_stuff(self):
self.do_this()
self.do_that()
if isInstance(self, B):
self.do_the_b_stuff()
elif isInstance(self, C):
self.do_the_c_stuff()
【问题讨论】:
标签: python self isinstance