count = 0
def __init__(self):
self.count+=1
class counter2:
count = 0
def __init__(self):
self.__class__.count+=1
print counter.count # 类的属性
b=counter() # instance of class counter
print b.count
c=counter() # instance of class counter
print c.count
# 比较一下 self.__class__.count 与 self.count 结果的区别
d=counter2() # instance of class counter
print d.count
e=counter2() # instance of class counter
print d.count
print '**********help(b.__class__)**********'
print (b.__class__)
print '**********help(d.__class__)**********'
print help(d.__class__)
版权声明:本文为博主原创文章,未经博主允许不得转载。