使用元类,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'