Python Arguments __defaults__

There is an interesting example in the Python docs:

  1. # Python 3.5
  2. def f(a, L=[]):
  3. L.append(a)
  4. return L
  5.  
  6. print(f(1))
  7. print(f(2))
  8. print(f(3))
  9. # [1, 2, 3]

You can see how the arguments get stored within __defaults__ in the snippet below:

Python __defaults__