def friendly_number(number, base=1000, decimals=0, suffix='', powers=['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']):
 count = 0
 number = float(number)
 while ((number > base) and (count < len(powers))):
  number /= base
  count += 1
 if decimals:
  fmt = ('%%.%df%%s%%s' % decimals)
 else:
  number = round(number)
  fmt = '%d%s%s'
 return (fmt % (number, powers[count], suffix))

def friendly_number ( number , base = 1000 , decimals = 0 , suffix = '' , powers = [ '' , 'k' , 'M' , 'G' , 'T' , 'P' , 'E' , 'Z' , 'Y' ] ) : count = 0 number = float ( number ) while ( ( number > base ) and ( count < len ( powers ) ) ) : number /= base count += 1 if decimals : fmt = ( '%%.%df%%s%%s' % decimals ) else : number = round ( number ) fmt = '%d%s%s' return ( fmt % ( number , powers [ count ] , suffix ) )
format a number as friendly text .