PyObjects whose pystring method returns a multiline string have their first row misaligned when shown. For example
using PyCall
qiskit = pyimport("qiskit")
qc = qiskit.QuantumCircuit(1)
qc.x(0)
qc.draw()
gives
PyObject ┌───┐
q_0: ┤ X ├
└───┘
A fix would be to replace
function show(io::IO, o::PyObject)
print(io, "PyObject $(pystring(o))")
end
with
function show(io::IO, o::PyObject)
str = pystring(o)
sep = contains(str, "\n") ? "\n" : " " # Avoid misaligning the first line for multiline prints
print(io, "PyObject$sep$str")
end
PyObjects whose pystring method returns a multiline string have their first row misaligned when shown. For example
gives
A fix would be to replace
with
which gives the following print instead.