Question about Pass-by-object-reference?

fl rxjwg98 at gmail.com
Tue Jul 22 18:31:21 EDT 2014


On Tuesday, July 22, 2014 4:46:25 PM UTC-4, emile wrote:
> On 07/22/2014 01:35 PM, Peter Pearson wrote:
> def reassign(mylist):  # no reason to shadow the list builtin
>      mylist[:] = [0,1]
> 
> mylist = [1]
> reassign(mylist)
> mylist
> 
> Emile

I have a new question on the code. When I run it in a file on PythonWin, 'mylist'
does not echo anything on the screen. While I enter the command line by line,
'mylist' shows the result:

>>> mylist
[0, 1]


What mechanism is involved?

Thanks,



More information about the Python-list mailing list