Mutable Stings

Griebel, Peer Peer.Griebel at
Mon Sep 16 09:01:38 EDT 2002


I do understand that strings are immutable. This is the reason (I think)
that the class str does not define the methods e.g. __iadd__().

Now I had a look at It says that the class UserString
provides a wrapper class for immutable strings. Therefore it can safely
define the method hash(). (In contrast the class MutableString raises an
exception when hash() is going to be called.)

My problem now is that UserString does provide the method __iadd__ which
does an in-place modification of the string (! This would result
in a non constant hash value!

So my question: Is this correct - or did I overlook something?

connection reset by

Dr. Peer Griebel                     Tel: +49(0) 731 / 9 74 95-0
Dipl. Inform.                       Fax: +49(0) 731 / 9 74 95-20
Entire Software AG                 mailto:Peer.Griebel at
Pfarrer-Weiß-Weg 10 - 12
D-89077 Ulm                       

More information about the Python-list mailing list