Getting list of operations from a function without @qml.template

With the @qml.template decorator now gone I am wondering what the recommended way is to get a list of operations that would be put on the tape by a function without a reference to a device.

Essentially the new best practice to do the equivalent of this:

import pennylane as qml
@qml.template
def f():
    qml.PauliX(wires=0)
    qml.PauliY(wires=1)

print(f())
[PauliX(wires=0), PauliY(wires=0)]

Hi @cvjjm, the easiest way is to use a Quantum tape to register your operations. Then it is simple to print the operations registered in the tape.

def f():
    qml.PauliX(wires=0)
    qml.PauliY(wires=1)

with qml.tape.QuantumTape() as tape:
    f()

print(tape.operations) 

The output:

[PauliX(wires=[0]), PauliY(wires=[1])]

If you have questions about tapes, let us know!

Thanks! That is all I wanted to know!