使用元类,metaclass

2018-03-30  本文已影响2人  shuff1e
class test(object):
    pass
t=test()
t.name='hello'
print t.name    #hello                                                                                                                                
print test.name    #AttributeError: type object 'test' has no attribute 'name'
上一篇 下一篇

猜你喜欢

热点阅读