def format_bytes_to_human(size, precision=2):
 size = int(size)
 fmt = ('%%1.%df %%s' % precision)
 for unit in ['B', 'KB', 'MB', 'GB', 'TB']:
  if (size < 1024.0):
   return (fmt % (size, unit))
  size /= 1024.0

def format_bytes_to_human ( size , precision = 2 ) : size = int ( size ) fmt = ( '%%1.%df %%s' % precision ) for unit in [ 'B' , 'KB' , 'MB' , 'GB' , 'TB' ] : if ( size < 1024.0 ) : return ( fmt % ( size , unit ) ) size /= 1024.0
format a byte value to a human readable representation .