def table_lines_from_stats(stats, old_stats, columns):
 lines = []
 for m_type in columns:
  new = stats[m_type]
  format = str
  if isinstance(new, float):
   format = (lambda num: ('%.3f' % num))
  old = old_stats.get(m_type)
  if (old is not None):
   diff_str = diff_string(old, new)
   old = format(old)
  else:
   (old, diff_str) = ('NC', 'NC')
  lines += (m_type.replace('_', ' '), format(new), old, diff_str)
 return lines

def table_lines_from_stats ( stats , old_stats , columns ) : lines = [ ] for m_type in columns : new = stats [ m_type ] format = str if isinstance ( new , float ) : format = ( lambda num : ( '%.3f' % num ) ) old = old_stats . get ( m_type ) if ( old is not None ) : diff_str = diff_string ( old , new ) old = format ( old ) else : ( old , diff_str ) = ( 'NC' , 'NC' ) lines += ( m_type . replace ( '_' , ' ' ) , format ( new ) , old , diff_str ) return lines
get values listed in <columns> from <stats> and <old_stats> .