def CreateCGate(name, latexname=None):
    if not latexname:
        latexname = name
    onequbitgate = CreateOneQubitGate(name, latexname)
    def ControlledGate(ctrls,target):
        return CGate(tuple(ctrls),onequbitgate(target))
    return ControlledGate
Use a lexical closure to make a controlled gate.
dataset/ETHPy150Open sympy/sympy/sympy/physics/quantum/circuitplot.py/CreateCGate