Exemple #1
0
 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
Exemple #2
0
 def replace(self, data):
     removed = self.struct[self.index]
     self.struct[self.index] = data
     Proxy.reproxy(self.struct.proxy, self.index, data)
     return removed