Module UserString :: Class MutableString
[hide private]
[frames] | no frames]

_ClassType MutableString

UserString --+
             |
            MutableString

mutable string objects

Python strings are immutable objects. This has the advantage, that strings may be used as dictionary keys. If this property isn't needed and you insist on changing string values in place instead, you may cheat and use MutableString.

But the purpose of this class is an educational one: to prevent people from inventing their own mutable string class derived from UserString and than forget thereby to remove (override) the __hash__ method inherited from UserString. This would lead to errors that would be very hard to track down.

A faster and better solution is to rewrite your program using lists.

Instance Methods [hide private]
 
__init__(self, string='')
 
__hash__(self)
 
__setitem__(self, index, sub)
 
__delitem__(self, index)
 
__setslice__(self, start, end, sub)
 
__delslice__(self, start, end)
 
immutable(self)
 
__iadd__(self, other)
 
__imul__(self, n)

Inherited from UserString: __add__, __cmp__, __complex__, __contains__, __float__, __getitem__, __getslice__, __int__, __len__, __long__, __mod__, __mul__, __radd__, __repr__, __rmul__, __str__, capitalize, center, count, decode, encode, endswith, expandtabs, find, index, isalnum, isalpha, isdecimal, isdigit, islower, isnumeric, isspace, istitle, isupper, join, ljust, lower, lstrip, partition, replace, rfind, rindex, rjust, rpartition, rsplit, rstrip, split, splitlines, startswith, strip, swapcase, title, translate, upper, zfill

Method Details [hide private]

__init__(self, string='')
(Constructor)

 
Overrides: UserString.__init__

__hash__(self)
(Hashing function)

 
Overrides: UserString.__hash__