David Lowry-Duda <da...@lowryduda.com> writes:

   ...

   For the same reason that the following code doesn't do what some people 
   might expect it to:

   ```python
   def add_to(elem, inlist=[]):
       inlist.append(elem)
       return inlist

   list1 = add_to(1)
   list2 = add_to(2)
   print(list1)  # prints [1]
   print(list2)  # prints [1, 2], potentially confusing
   ```

Not only does it not print what "most people" expect.  It also doesn't
print what _you_ expect!  (But you made your point.)
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to