I am trying to understand what exactly is a Python name binding, and when is this binding interpreted.
In c
include <stdio.h>
int main()
{
int X = 42;
int* Y[1];
Y[0] = &X;
X = 666;
printf("%d", *Y[0]);
return 0;
}
prints 666. I was expecting a block of Python code:
X = 42
L = []
L.append(X)
X = 666
print(L)
do the same, but it’s not. What exactly happens between the lines labeled 3 and 5? # 3 makes another reference to an object known as "42", for example X, allows you to call it X 'and store X' in the object pointed to by L, which is []?
source
share