摘要: 学习python这么久对python的metaclass还是一知半解,网上找了找,发现stackoverflow太强大了: http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python 这个回答很详细,太厉害了,这里自己总结一下,免的忘记。1. 类也是对象(class are object), 类在内存中也占有一段空间,所以class Foo(object):pass id(Foo) #有值 Foo.bar = 'bar' #给类添加一个属性2. 可以动态的创建类type(class_name, 阅读全文
posted @ 2011-09-05 13:56 酱油哥 阅读(574) 评论(0) 推荐(0)