UserString.MutableString¶
-
class
UserString.MutableString(string='')[source]¶ 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.
Methods¶
__add__(other) |
|
__cmp__(string) |
|
__complex__() |
|
__contains__(char) |
|
__delitem__(index) |
|
__delslice__(start, end) |
|
__float__() |
|
__format__ |
default object formatter |
__getitem__(index) |
|
__getslice__(start, end) |
|
__iadd__(other) |
|
__imul__(n) |
|
__init__([string]) |
|
__int__() |
|
__iter__() |
|
__len__() |
|
__long__() |
|
__mod__(args) |
|
__mul__(n) |
|
__new__((S, ...) |
|
__radd__(other) |
|
__reduce__ |
helper for pickle |
__reduce_ex__ |
helper for pickle |
__repr__() |
|
__reversed__() |
|
__rmul__(n) |
|
__setitem__(index, sub) |
|
__setslice__(start, end, sub) |
|
__sizeof__(() -> int) |
size of object in memory, in bytes |
__str__() |
|
__subclasshook__(C) |
|
append(value) |
S.append(object) – append object to the end of the sequence |
capitalize() |
|
center(width, *args) |
|
count(sub[, start, end]) |
|
decode([encoding, errors]) |
|
encode([encoding, errors]) |
|
endswith(suffix[, start, end]) |
|
expandtabs([tabsize]) |
|
extend(values) |
S.extend(iterable) – extend sequence by appending elements from the iterable |
find(sub[, start, end]) |
|
immutable() |
|
index(sub[, start, end]) |
|
insert(index, value) |
|
isalnum() |
|
isalpha() |
|
isdecimal() |
|
isdigit() |
|
islower() |
|
isnumeric() |
|
isspace() |
|
istitle() |
|
isupper() |
|
join(seq) |
|
ljust(width, *args) |
|
lower() |
|
lstrip([chars]) |
|
partition(sep) |
|
pop(...) |
Raise IndexError if list is empty or index is out of range. |
remove(value) |
S.remove(value) – remove first occurrence of value. |
replace(old, new[, maxsplit]) |
|
reverse() |
S.reverse() – reverse IN PLACE |
rfind(sub[, start, end]) |
|
rindex(sub[, start, end]) |
|
rjust(width, *args) |
|
rpartition(sep) |
|
rsplit([sep, maxsplit]) |
|
rstrip([chars]) |
|
split([sep, maxsplit]) |
|
splitlines([keepends]) |
|
startswith(prefix[, start, end]) |
|
strip([chars]) |
|
swapcase() |
|
title() |
|
translate(*args) |
|
upper() |
|
zfill(width) |