I am trying to fully understand the principle of "Stack Diagram" . Can someone check if I'm right, please?
So far, I understand that the stack diagram is used to track the variables used in functions inside the code.
However, I'm not sure if a new variable is created in a specific function if it is included in the stack diagram.
For example, should I include the variable "p" in the stack diagram? Let them talk:
def g(y): p = A(y, y) print z, p return p def A(x, y): x = x + 1 return x * y x = 1 y = x + 2
I think my stack should look something like this:
<module> x --> 1 y --> 3 (Should I put 3 or x + 2 here) fct gy --> 3 (should I stop here or should I include a line for the variable p) fct A x --> 4 y --> 3
Last question: is it worth mentioning anything about what other things the function performs. As with function A, it returns x * y = 12. Should we include this in the stack diagram or the diagram correctly, how is it?
thanks
source share