API Reference: qiskit.circuit.QuantumCircuit.append
The QuantumCircuit.append method attaches a custom instruction or gate to a circuit. The main parameters are instruction, qargs, and optionally cargs. The instruction defines the operation, while qargs identifies the qubits it acts on.
This method is appropriate when a reusable subcircuit has been converted into a gate or instruction. It allows higher-level algorithms to treat a composite operation as a single circuit element that can later be decomposed by the transpiler.
Parameters
| Parameter Name | Type | Description |
|---|---|---|
instruction |
Instruction | Gate |
The operation to append to the circuit. |
qargs |
list |
The qubits on which the instruction acts. |
cargs |
list | None |
Optional classical bits used by the instruction. |
from qiskit import QuantumCircuit
sub = QuantumCircuit(1)
sub.h(0)
QuantumCircuit(1).append(sub.to_gate(label="HBlock"), [0])
Example Output
{
"status": "success",
"operation": "AppendInstruction",
"label": "HBlock",
"qargs": [0]
}
Used In Technical Article
Qiskit v1.2 Quantum Circuit Optimization via Shannon Decomposition