Is there a way in Qiskit to take a circuit object and return a list of tuples where each tuple consists of a gate and the qubit(s) they act on? The list obeys some partial order since the gate order cannot be swapped unless they commute.


1 Answer 1


You can inspect the QuantumCircuit.data structure:


For example, here is a loop that prints the name, qubits and any other parameters for all the gates in a circuit.

for gate in qc.data:
    print('\ngate name:', gate[0].name)
    print('qubit(s) acted on:', gate[1])
    print('other paramters (such as angles):', gate[0].params)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.