Next / Previous / Contents / Shipman's homepage

11.3. KwicRef.__str__()

For the explanation of this method, see Section 4.3, “Using the KwicRef class”.

kwic.py
# - - -   K w i c R e f . _ _ s t r _ _

    def __str__(self):
        '''Return a string representation of self.
        '''
        #-- 1 --
        L = [ self.word ]

        #-- 2 --
        if len(self.suffix) > 0:
            L.append(" %s" % self.suffix)

        #-- 3 --
        if len(self.prefix) > 0:
            L.append (", %s" % self.prefix)

        #-- 4 --
        return ''.join(L)