def str2num(string):
    """Numeric value (``int`` or ``float``) of a string, if possible."""
    try:
        return int(string)
    except:
        try:
            return float(string)
        except:
            pass
    return string
