#NEWLINE# def table( self , rows = [ ] , headers = [ ] , striped = True , **attributes ) : #NEWLINE# #INDENT# ' Returns a string with a HTML <table> for the given list,\n            where each item is a list of values.\n            With striped=True, generates <tr class="even|odd">.\n            With striped=True and headers, generates <td class="header[i]">.\n        ' #NEWLINE# h = list ( headers ) #NEWLINE# r = ( list ( rows ) if ( not h ) else ( [ h ] + list ( rows ) ) ) #NEWLINE# a = [ ( '<table%s>\n' % self . _attrs ( ** attributes ) ) ] #NEWLINE# if h : #NEWLINE# #INDENT# a . append ( '\t<colgroup>\n' ) #NEWLINE# a . extend ( ( ( '\t\t<col class="%s">\n' % v ) for v in h ) ) #NEWLINE# a . append ( '\t</colgroup>\n' ) #NEWLINE# #UNINDENT# for ( i , row ) in enumerate ( r ) : #NEWLINE# #INDENT# a . append ( ( '\t<tr%s>\n' % ( ( ' class="%s"' % ( 'odd' , 'even' ) [ ( i % 2 ) ] ) if striped else '' ) ) ) #NEWLINE# for ( j , v ) in enumerate ( row ) : #NEWLINE# #INDENT# if ( ( i == 0 ) and h ) : #NEWLINE# #INDENT# a . append ( ( '\t\t<th>%s</th>\n' % v ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# a . append ( ( '\t\t<td>%s</td>\n' % v ) ) #NEWLINE# #UNINDENT# #UNINDENT# a . append ( '\t</tr>\n' ) #NEWLINE# #UNINDENT# a . append ( '</table>\n' ) #NEWLINE# return '' . join ( a )