Trying to understand Python static variables, and the following confuses me:
>>> class Foo():
... a = [1]
...
>>> f = Foo()
>>> Foo.a.append(2)
>>> Foo.a
[1, 2]
>>> f.a
[1, 2]
>>> f.a.append(3)
>>> f.a
[1, 2, 3]
>>> Foo.a
[1, 2, 3]
>>> # appears that Foo.a and f.a reference same list object
...
>>> Foo.a = 3
>>> f.a
3
>>> Foo.a
3
Based on the top answer to this question (Static class variables in Python), I would expect that Foo.a and f.a are separate names, but that f.a is just first initialized to Foo.a. This explanation works if you first try to modify the object through Foo.a or reassign f.a, but I am confused by the last few lines. I would expect Foo.a = 3 to only reassign Foo.a, but it seems to have reassigned f.a as well, as it is no longer referencing the list object. If you assign to f.a first, reassignment of Foo.a does not change f.a, so it seems f.a is syntatic sugar for Foo.a until f.a is explicitly assigned to. Is this correct?