"zzzzz" <zzizz_ at notmail.com> wrote in message news:bnj7dto6gf5859sd7sl4v00ch6ue7ejagl at 4ax.com... > Hi all, > > I (possibly incorrectly) thought that parameters passed in functions > were modifiable by default in Python, here is some code that I tested A function is passed (references to) objects that may be either modifiable (e.g., lists) or not (e.g., tuples). > It looks like "parameter=[2,4,6,8]" creates a new local variable that No, it just *RE-BINDS* your local variable 'parameter' so it now refers to this new list object -- which has no effect on whatever 'parameter' was previously bound to, and has nothing to do with modifiable objects. Assuming 'parameter' is currently bound to a list (e.g., that a list object was passed as the corresponding actual parameter), you can perform modifying-operations on the list you were passed in; e.g., the modification "substitute all of the list contents": parameter[:] = [2, 4, 6, 8] Alex
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4