+ 1
Does default parameters in python function have memory at declaration time?
I have function with a default parameter y which is a list. This function append the first parameter into the list and return it. When I ran the program several times, I found when i pass only single parameter it keep going into the same list, or when i pass a new list as a second parameter it only return list with one element only. I have checked the address of the default parameter and it is same when only one parameter is passed and different when two parameters are passed. Does it mean in python memory is allocated to the default parameter at declaration time? https://code.sololearn.com/cnI89Sd3LGaO/?ref=app
2 Answers
+ 1
I found this hope this help you.
https://docs.python.org/2.0/ref/function.html
0
Emanuel Maliaño thanks