ends(s) is TRUE <=> k0,...k ends with the string s.

def ends(self, s):
        """ends(s) is TRUE <=> k0,...k ends with the string s."""
        length = len(s)
        if s[length - 1] != self.b[self.k]:  # tiny speed-up
            return 0
        if length > (self.k - self.k0 + 1):
            return 0
        if self.b[self.k - length + 1 : self.k + 1] != s:
            return 0
        self.j = self.k - length
        return 1