All pastes #775744 Raw Edit

Stuff

public text v1 · immutable
·published 2007-11-15 18:34 UTC
rendered paste body
class MyString(str):
        def __sub__(self, y):
                if isinstance(y, basestring):
                        substr = y
                        subpos = 0
                else:
                        substr, subpos = y

                if subpos == 0:
                        return self.replace(substr, "")

                if subpos > 0:
                        l = self.split(substr, subpos)
                else:
                        l = self.rsplit(substr, abs(subpos))

                return substr.join(l[:subpos]) + substr.join(l[subpos:])

x = MyString("TheBookToEndAllBooks")
print x - "Book"