[i=s] 本帖最后由 jieforest 于 2012-7-6 11:05 编辑
In this post we will be talking about Metaclass in python. If you are reading some code which uses metaclass, you will probably come across __new__. If you are not familiar with what __new__ does, i suggest you first read about __new__.
You can read about __new__ in our last to last post.
Throughout this post we will be talking about new style. classes. Things might differ in old-style. classes.
As we go, i will be trying everything on IPython and suggest you as well to try everything on IPython.
Let's see a little bit about normal Objects in Python.
>>> class A(object):
...We created a class named A. A extends from class object (Here by object we mean class named object from which all new style. classes extend).
Hereafter if we use lowercase 'o' in object, it means we want to refer to the class named object. If we use an Object with uppercase 'O', we mean an instance of some class i.e an instance created by calling the class.
Let's create an instance of A.
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/301743/viewspace-734765/，如需转载，请注明出处，否则将追究法律责任。