def print_table(self, items, fields):
        """ print a table of items, for a set of fields defined

            Parameters
            ==========
            items: a list of items to print
            fields: a list of fields to select from items
        """
        formats = []
        borders = []
        for f in fields:
            length = max(
                len(f), max([len(self.string(getattr(i, f))) for i in items]))
            justify = '>' if isinstance(getattr(
                items[0], f), int) or f == 'size' or f == 'reward' else '<'
            formats.append('{:' + justify + self.string(length + 2) + '}')
            borders.append('-' * length + '  ')
        row_format = u''.join(formats)
        headers = [f + '  ' for f in fields]
        print(row_format.format(*headers))
        print(row_format.format(*borders))
        for i in items:
            i_fields = [self.string(getattr(i, f)) + '  ' for f in fields]
            try:
                print(row_format.format(*i_fields))
            except UnicodeEncodeError:
                print(row_format.format(*i_fields).encode('utf-8'))
def print_table ( self , items , fields ) : formats = [ ] borders = [ ] for f in fields : length = max ( len ( f ) , max ( [ len ( self . string ( getattr ( i , f ) ) ) for i in items ] ) ) justify = '>' if isinstance ( getattr ( items [ 0 ] , f ) , int ) or f == 'size' or f == 'reward' else '<' formats . append ( '{:' + justify + self . string ( length + 2 ) + '}' ) borders . append ( '-' * length + '  ' ) row_format = u'' . join ( formats ) headers = [ f + '  ' for f in fields ] print ( row_format . format ( * headers ) ) print ( row_format . format ( * borders ) ) for i in items : i_fields = [ self . string ( getattr ( i , f ) ) + '  ' for f in fields ] try : print ( row_format . format ( * i_fields ) ) except UnicodeEncodeError : print ( row_format . format ( * i_fields ) . encode ( 'utf-8' ) )
print a table of items, for a set of fields defined

            Parameters
            ==========
            items: a list of items to print
            fields: a list of fields to select from items