[docs] [issue20135] mutate list

R. David Murray report at bugs.python.org
Mon Jan 6 04:53:55 CET 2014


R. David Murray added the comment:

Both of these are FAQs, but to my surprise there don't seem to be answers to them in the FAQ list.  We should add some.

Yes, both of these behaviors is intentional.  The first is an important part of the language design: 'variable' names are just pointers to objects, so x and y point to the same object.  The second is the same issue combined with another design feature: the objects on the right side of the = in a def statement are evaluated/created at the time the def statement is executed, not at the time the function is called.  So 'n' points to the same object every time the function is called.

I'm going to leave this open until someone either points me to the FAQ entries I missed, or we add them.

----------
assignee:  -> docs at python
components: +Documentation
nosy: +docs at python, r.david.murray
versions: +Python 2.7, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20135>
_______________________________________


More information about the docs mailing list