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

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 .