Say I have a function foo that takes a list baz, and in foo I wanted to clear baz like so:
baz = []
foo(baz)
foo(baz):
baz = []
Now, this code does not do what I would want it to do, because it creates a new local list called baz. I know that there are other ways of doing this, but I would like to know Python resolves ambiguities like this where the statement
baz = []
could be interpreted as telling Python to point the outer scope baz variable at a new empty chunk of memory or to create a new pointer pointing to an empty chunk of memory.
EDIT
Please be aware that I am not asking how to clear a list. I am asking about the behavior of the Python interpreter. Please read the question clearly before downvoting.