def FormatThousands(value):
 if isinstance(value, float):
  value = ('%.2f' % value)
 else:
  value = str(value)
 if ('.' in value):
  (head, tail) = value.split('.', 1)
  tail = ('.' + tail)
 elif ('e' in value):
  (head, tail) = value.split('e', 1)
  tail = ('e' + tail)
 else:
  head = value
  tail = ''
 sign = ''
 if head.startswith('-'):
  sign = '-'
  head = head[1:]
 while (len(head) > 3):
  tail = ((',' + head[(-3):]) + tail)
  head = head[:(-3)]
 return ((sign + head) + tail)

def FormatThousands ( value ) : if isinstance ( value , float ) : value = ( '%.2f' % value ) else : value = str ( value ) if ( '.' in value ) : ( head , tail ) = value . split ( '.' , 1 ) tail = ( '.' + tail ) elif ( 'e' in value ) : ( head , tail ) = value . split ( 'e' , 1 ) tail = ( 'e' + tail ) else : head = value tail = '' sign = '' if head . startswith ( '-' ) : sign = '-' head = head [ 1 : ] while ( len ( head ) > 3 ) : tail = ( ( ',' + head [ ( - 3 ) : ] ) + tail ) head = head [ : ( - 3 ) ] return ( ( sign + head ) + tail )
format a numerical value .