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

甜瓜 littlesweetmelon at gmail.com
Fri Mar 30 05:23:31 EDT 2007


No, I don't think so. ^_^ You can see it from the last lines in you
recommend document:
>>> d.count
2
>>> c.count
2

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
Again, instance p & q share the class attribute "i".

--
ShenLei




More information about the Twisted-Python mailing list