标签:font turn 条件 class color new print obj ack
class Car(object):
__name = 1
__name2 = 0
def __new__(cls):
if __name:
__name = 0
__name2 = object.__new__(cls) 条件不满足重新调用父类方法就行
else:
return __name2
a = Car()
b = Car()
print(id(a))
print(id(b))
标签:font turn 条件 class color new print obj ack
原文地址:http://www.cnblogs.com/lvhonglei-python/p/7071316.html