__new__:创建对象时调用,返回当前对象的一个实例
__init__:创建完对象后调用,对当前对象的实例的一些初始化,无返回值案例一:
>>> class A(object):def __init__(self): print("in init")def __new__(self): print("in new")
>>> A()in new
案例二:
class A(object): def __new__(Class): Object = super(A, Class).__new__(Class) print "in New" return Object def __init__(self): print "in init"class B(A): def __init__(self): print "in B's init"B()
>>> in Newin B's init