in the following code when i use del
keyword to delete the formal parameter a
, and then print it outside the function the list that is passed still exists.
lst = [1,2,3]
def func(a):
print lst
lst.append(4) #this is modified as it is by default passed by reference
print lst
print locals
del a # this does not delete the lst! why?
print locals
func(a)
print lst #still exists!