def memory_setting(label):
 suffixes = {u'K': 1000.0, u'M': (1000.0 ** 2), u'G': (1000.0 ** 3), u'T': (1000.0 ** 4)}
 try:
  mem = float(label)
  return mem
 except ValueError:
  prefix = label[:(-1)]
  suffix = label[(-1):].upper()
  if (suffix not in suffixes.keys()):
   raise ValueError(u'cannot parse memory setting "{}"'.format(label))
  try:
   multiplier = float(prefix)
   return (multiplier * suffixes[suffix])
  except ValueError:
   raise ValueError(u'cannot parse memory setting "{}"'.format(label))

def memory_setting ( label ) : suffixes = { u'K' : 1000.0 , u'M' : ( 1000.0 ** 2 ) , u'G' : ( 1000.0 ** 3 ) , u'T' : ( 1000.0 ** 4 ) } try : mem = float ( label ) return mem except ValueError : prefix = label [ : ( - 1 ) ] suffix = label [ ( - 1 ) : ] . upper ( ) if ( suffix not in suffixes . keys ( ) ) : raise ValueError ( u'cannot parse memory setting "{}"' . format ( label ) ) try : multiplier = float ( prefix ) return ( multiplier * suffixes [ suffix ] ) except ValueError : raise ValueError ( u'cannot parse memory setting "{}"' . format ( label ) )
parse user-supplied memory setting .