T
Tor Erik Soenvisen
Hi,
What do I need to do to make the code below work as expected:
class str2(str):
def __setitem__(self, i, y):
assert type(y) is str
assert type(i) is int
assert i < len(self)
self = self[:i] + y + self[1+i:]
a = str2('123')
a[1] = '1'
print a
123
The print statement should return 113
Regards tores
What do I need to do to make the code below work as expected:
class str2(str):
def __setitem__(self, i, y):
assert type(y) is str
assert type(i) is int
assert i < len(self)
self = self[:i] + y + self[1+i:]
a = str2('123')
a[1] = '1'
print a
123
The print statement should return 113
Regards tores