[Twisted-Python] Why classes in twisted.protocols.basic use "static member" to store states?

Tim Allen screwtape at froup.com
Fri Mar 30 04:04:18 MDT 2007


On 30 Mar 2007, at 19:23, 甜瓜 wrote:
> Instance c & d indeed share the class attribute "count". You can try
> it more explicitly:
>>>> class A:
> ...     i = 0
> ...
>>>> p = A()
>>>> q = A()
>>>> A.i = 2
>>>> p.i
> 2
>>>> q.i
> 2

Ah, but continuing:

 >>> p.i = 5
 >>> p.i
5
 >>> q.i
2

i is still not a class attribute in the same way it might be for Java  
or C++.



More information about the Twisted-Python mailing list