mutable string implementation python.
#mutable string class in python
class Mstring:
def __init__(self, string=None):
if string:
self.string = list(string)
else:
self.string = []
def __repr__(self):
return str(self.string)
def __setitem__(self, key, value):
assert value.__class__ is str
self.string[key] = value
def tostring(self):
return ''.join(self.string)