(self)
return '\n'.join(row_strs)
Return an ascii representation of the screen buffer (for debugging).
Return an ascii representation of the screen buffer (for debugging).
Return an ascii representation of the screen buffer ( for debugging ) .
def __repr__(self):
        """Return an ascii representation of the screen buffer (for debugging)."""
        horiz_bar = ('   +' + '-' * self._width + '+')
        row_strs = []
        lastwrap = False
        row_strs.append(horiz_bar)
        for i, row in enumerate(self._rows):
            # replace non-ascii with ? - this is not ideal but
            # for python2 we need to stick to ascii-128 so implicit conversion to bytes works
            # and for python3 we must use unicode
            # and backslashreplace messes up the output width...
            rowstr = ''.join(
                _char.decode('ascii', 'replace').replace(u'\ufffd', u'?')
                for _char in row.chars
            )
            left = '\\' if lastwrap else '|'
            right = '\\' if row.wrap else '|'
            row_strs.append('{0:2} {1}{2}{3} {4:2}'.format(
                i, left, rowstr, right, row.length,
            ))
            lastwrap = row.wrap
        row_strs.append(horiz_bar)
        return '\n'.join(row_strs)
def __repr__ ( self ) : horiz_bar = ( '   +' + '-' * self . _width + '+' ) row_strs = [ ] lastwrap = False row_strs . append ( horiz_bar ) for i , row in enumerate ( self . _rows ) : # replace non-ascii with ? - this is not ideal but # for python2 we need to stick to ascii-128 so implicit conversion to bytes works # and for python3 we must use unicode # and backslashreplace messes up the output width... rowstr = '' . join ( _char . decode ( 'ascii' , 'replace' ) . replace ( u'\ufffd' , u'?' ) for _char in row . chars ) left = '\\' if lastwrap else '|' right = '\\' if row . wrap else '|' row_strs . append ( '{0:2} {1}{2}{3} {4:2}' . format ( i , left , rowstr , right , row . length , ) ) lastwrap = row . wrap row_strs . append ( horiz_bar ) return '\n' . join ( row_strs )