I have quite a bit of experience with C/C++ and have recently started coding more often in Python but I am no expert yet. I am noticing this interesting behaviour and I am not exactly sure what to attribute it to. I have a recursive function that looks like this:
def fun(param=[]):
# do something
fun()
I notice that, as I recursively enter fun()
, the modified list param
is 'forwarded' (for lack of a better word) along. I am surprised that I don't need to call fun(param)
to carry param
from one call to another. Why is that? As a C++ developer, that weirds me out.