It is believed that lists in python as a mutable object are passed by reference. However when I try to change the list passed to a function to be assigned by another list, particularly empty list, the change is not observable in the caller.
Giving more details here is my code:
def callee(l):
l = list() # this could be any list but my interest was empty list
def caller():
l = [1, 2, 3]
caller(l)
print(l) # prints [1, 2, 3] while I expect an empty list
How can I remove all elements of a list in the callee function?
When I change one particular element of a list in the callee, it is observable in the caller. What kind of passing is this, call-by-value or call-by-reference? I believe neither and I appreciate any clarification on this too.