Problem
In Julia, one could easily see the value of intermediate variable using @show
marco for debugging purposes. For example
for i in 1:5
@show i ^ 2
end
which will output
i ^ 2 = 1
i ^ 2 = 4
i ^ 2 = 9
i ^ 2 = 16
i ^ 2 = 25
However, in order to show intermediate value in Python, one have to write print("<variable> = " + ...)
, which is too much work for debugging a large project. I am wondering if there is any way that could enable Python to have similar functionality as in Julia.
I previously saw people use decorator to acquire the program runtime (see here), which is quite similar to Julia marco. But I do not know how to get it to work here to show intermediate variable.
Could someone help me, thank you in advance!