interview_python icon indicating copy to clipboard operation
interview_python copied to clipboard

资料有一处错误

Open lylandroid opened this issue 6 years ago • 3 comments

您好,最近正在学习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

lylandroid avatar May 10 '18 08:05 lylandroid

这是我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.

tao625 avatar May 10 '18 09:05 tao625

握手

lylandroid avatar May 10 '18 12:05 lylandroid

如果使用Python2.*,经典类(深度优先算法)的结果就是A,只有使用新式类<C3算法>(继承自object)的返回才是C.

# 经典类
class A:
    pass
# 新式类
class A(object): 
    pass

imoyao avatar Apr 13 '19 02:04 imoyao