Python with_metaclass 继承测试
#!/usr/bin/pythonfrom six import with_metaclassclass A(type):def TestA(self):print('TestA')class B(object):def TestB(self):print('TestB')class C(with_metaclass(A,B)):def TestC(...
·
#!/usr/bin/python
from six import with_metaclass
class A(type):
def TestA(self):
print('TestA')
class B(object):
def TestB(self):
print('TestB')
class C(with_metaclass(A,B)):
def TestC(self):
print('TestC')
c=C()
c.TestC()
c.TestB()
c.TestA()
输出结果:
TestC
TestB
Traceback (most recent call last):
File "/tmp/516425337/main.py", line 20, in <module>
c.TestA()
AttributeError: 'C' object has no attribute 'TestA'
exit status 1
更多推荐
已为社区贡献1条内容
所有评论(0)