Next / Previous / Contents / Shipman's homepage

28. Puzzle.__showColHeads(): Column headings for .show()

For the general layout, see Section 27, “Puzzle.show(): Display the state of the puzzle”.

kkck
# - - -   P u z z l e . _ _ s h o w C o l H e a d s

    def __showColHeads ( self, rowList ):
        '''Add column headings to .show() output
        '''
        #-- 1 --
        # [ rowList  +:=  tens-digit line ]
        L = [ ' '*3 ]
        tensCount = (self.size[1]/10)+1
        for tens in range(tensCount):
            L.append ( "%d%s" % (tens, ' '*19) )
        rowList.append ( ''.join(L).rstrip() )

        #-- 2 --
        # [ rowList  +:=  units-digit line ]
        L = [ ' '*3 ]
        for colx in range(self.size[1]):
            L.append ( str(colx%10) )
            L.append ( ' ' )
        rowList.append ( ''.join(L) )