def format_size(size, base=1024, suffix=''):
 prefixes = ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']
 if (size is None):
  return ('?.??' + suffix)
 for p in prefixes:
  if ((- base) < size < base):
   return '{:.02f}{}{}'.format(size, p, suffix)
  size /= base
 return '{:.02f}{}{}'.format(size, prefixes[(-1)], suffix)

def format_size ( size , base = 1024 , suffix = '' ) : prefixes = [ '' , 'k' , 'M' , 'G' , 'T' , 'P' , 'E' , 'Z' , 'Y' ] if ( size is None ) : return ( '?.??' + suffix ) for p in prefixes : if ( ( - base ) < size < base ) : return '{:.02f}{}{}' . format ( size , p , suffix ) size /= base return '{:.02f}{}{}' . format ( size , prefixes [ ( - 1 ) ] , suffix )
format a byte size so its human readable .