-------------file name:att1.py-------------
class OneAttribute:
iA=1
--------------end file------------------------
在互動式環境下:
>>>from att1 import *
>>>OneAttribute.iA
1
>>> id(OneAttribute.iA)
7951280
>>>oaInstance1=OneAttribute()
>>>oaInstance2=OneAttribute()
>>> oaInstance1.iA, oaInstance2.iA
(1,1)
>>> id(oaInstance1.iA),id(oaInstance2.iA)
(7951280, 7951280)
>>> oaInstance1.iA=2
>>> oaInstance1.iA, oaInstance2.iA
(2,1)
>>>OneAttribute.iA=3
>>> oaInstance1.iA, oaInstance2.iA
(2,3)
>>> id(oaInstance1.iA),id(oaInstance2.iA)
(7951268, 7951280)
No comments:
Post a Comment