interview_python
interview_python copied to clipboard
资料有一处错误
您好,最近正在学习python,在你的资料中我学到了很多,很感谢你的分享;不过我好像看到一处错误,正确答案应该是:
C
class A(): def foo1(self): print "A" class B(A): def foo2(self): pass class C(A): def foo1(self): print "C" class D(B, C): pass
d = D() d.foo1()
A
这是我fork其他人还没来的急仔细看,刚刚看了下确实答案错了,谢谢指正,我最近也是在学习python,有机会多多交流心得
-- 梦星魂
在 2018-05-10 16:33:57,"lylandroid" [email protected] 写道:
您好,最近正在学习python,在你的资料中我学到了很多,很感谢你的分享;不过我好像看到一处错误,正确答案应该是:
C
class A(): def foo1(self): print "A" class B(A): def foo2(self): pass class C(A): def foo1(self): print "C" class D(B, C): pass
d = D() d.foo1()
A
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
握手
如果使用Python2.*
,经典类(深度优先算法)的结果就是A
,只有使用新式类<C3算法>(继承自object
)的返回才是C
.
# 经典类
class A:
pass
# 新式类
class A(object):
pass