def num_from_str(s):
    """Return a number from a string."""
    try:
        return int(s)
    except ValueError:
        try:
            return float(s)
        except ValueError:
            raise ValueError('Can not convert the string "' + s +
                '" into a numeric value.')
