On 12 Jul, 07:51, "Alf P. Steinbach /Usenet" <alf.p.steinbach
+use...@gmail.com> wrote:

> We're talking about defining a 'swap' routine that works on variables.

I did not miss the point. One cannot make a swap function that rebinds
its arguments in the calling stack frame. But a swap function can swap
values, given that the type is not immutable:

def swap(a,b):
   a[0],b[0] = b[0],a[0]

>>> a,b = [1],[2]
>>> swap(a,b)
>>> print a,b
[2] [1]

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to