def maybe_num(x):
    """Converts string x to an int if possible, otherwise a float if possible,
    otherwise returns it unchanged."""
    x = x.strip('[').strip(']')
    try: return int(x)
    except ValueError:
        try: return float(x)
        except ValueError: return x