def splice(self, start, stop, data): which = self.which if which in ('string', 'buffer'): immutable = self.struct[self.index] removed = immutable[start:stop] self.struct[self.index] = immutable[:start] + data + immutable[stop:] elif which == 'list': removed = self.struct[self.index][start:stop] self.struct[self.index][start:stop] = data else: raise Exception("Cannot splice %s" % which) Proxy.reproxy(self.struct.proxy, self.index, self.struct[self.index]) return removed
def replace(self, data): removed = self.struct[self.index] self.struct[self.index] = data Proxy.reproxy(self.struct.proxy, self.index, data) return removed