Assuming:
def myfunc(x): my_list = [] list.append(x)
is there a keyword to stop a variable(my_list) from being reassigned? Let\'s supp
I believe the behaviour you're seeking is almost exactly how mutable default arguments work in python: instantiated only during function definition.
def myfunc(x,*args,my_list=[]): my_list.append(x)
The *args will protect the list from being overwritten by an erroneously passed second argument.
*args