How to find out what `*` operator do on two objects from some library (cirq)?

52 Views Asked by At

I just started using python cirq library and I came across the following line of code in the tutorial:

XX_obs = cirq.X(q0) * cirq.X(q1)

I just want to find in the code what this * operator do on this two specific cirq objects. How to do so?

1

There are 1 best solutions below

0
On BEST ANSWER

First, you need to find what the type of cirq.X(q0) is:

print(type(cirq.X(q0)))

Then look for the definition, in that class, of the method __mul__. The __mul__ method of a class defines how an object behaves as a left operant of a multiplication operation.