def get_measure(argument, units):
 match = re.match(('^([0-9.]+) *(%s)$' % '|'.join(units)), argument)
 try:
  float(match.group(1))
 except (AttributeError, ValueError):
  raise ValueError(('not a positive measure of one of the following units:\n%s' % ' '.join([('"%s"' % i) for i in units])))
 return (match.group(1) + match.group(2))

def get_measure ( argument , units ) : match = re . match ( ( '^([0-9.]+) *(%s)$' % '|' . join ( units ) ) , argument ) try : float ( match . group ( 1 ) ) except ( AttributeError , ValueError ) : raise ValueError ( ( 'not a positive measure of one of the following units:\n%s' % ' ' . join ( [ ( '"%s"' % i ) for i in units ] ) ) ) return ( match . group ( 1 ) + match . group ( 2 ) )
check for a positive argument of one of the units and return a normalized string of the form "<value><unit>" .