def get_gate_info(gate):
    """
    gate: str, string gate. ie H(0), or "cx(1, 0)".
    returns: tuple, (gate_name (str), gate_args (tuple)).
    """
    gate = gate.strip().lower().replace("cnot", "cx")
    i = gate.index("(")
    gate_name, gate_args = gate[:i], eval(gate[i:])
    try: len(gate_args)
    except TypeError: gate_args = gate_args,
    return gate_name, gate_args