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

Tristan Seligmann mithrandi-twisted-python at mithrandi.za.net
Fri Mar 30 11:50:35 EDT 2007

* Tim Allen <screwtape at froup.com> [2007-03-30 20:04:18 +1000]:

> 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++.

It would probably be more correct to say that "value types" and
"assignment" work differently in Python compared with Java/C++. More
specifically, in Java/C++, "value types" like int or Integer are
mutable, and the "=" operator mutates them. In python, they are
immutable, and the "=" operator never mutates objects, but instead inds
a variable / attribute / etc. to a new object reference.
mithrandi, i Ainil en-Balandor, a faer Ambar
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20070330/63fa0988/attachment.pgp 

More information about the Twisted-Python mailing list