Re: Changing argument value

2007-12-15 Thread Tim Roberts
Stargaming <[EMAIL PROTECTED]> wrote: > >Even though you have the assignment operator *in both cases*, it does >**not** issue the same thing. > >As Bruno pointed out, in the first case ``y = [3,4]`` it is *rebinding* >the name `y`. There have been two good replies to this, but I would like to p

Re: Changing argument value

2007-12-14 Thread Stargaming
On Thu, 13 Dec 2007 22:52:56 +0100, Bruno Desthuilliers wrote: > flyfree a écrit : [snip] >> What is the difference between "y = [3,4]" and "y[0]=3 y[1] =4 " > > In the first case, you rebind the local name y to a new list object - > and since the name is local, rebinding it only affects the loca

Re: Changing argument value

2007-12-13 Thread Bruno Desthuilliers
flyfree a écrit : def fooA(y): > > y = [3,4] > return y > > def fooB(y): > > y[0] = 3 > y[1] = 4 > return y > > x = [1,2] fooA(x) > > [3, 4] > x > > [1, 2] > > fooB(x) > > [3, 4] > x > > [3, 4] > === > > From above

Changing argument value

2007-12-13 Thread flyfree
>>> def fooA(y): y = [3,4] return y >>> def fooB(y): y[0] = 3 y[1] = 4 return y >>> x = [1,2] >>> fooA(x) [3, 4] >>> x [1, 2] >>> fooB(x) [3, 4] >>> x [3, 4] === >From above, the original argument value of fooA is same as before [1,2] but the