[EMAIL PROTECTED] wrote: > On Apr 20, 4:37 pm, John Machin <[EMAIL PROTECTED]> wrote: > >>One inessential but very useful thing about tuples when you have a lot >>of them is that they are allocated the minimum possible amount of >>memory. OTOH lists are created with some slack so that appending etc >>can avoid taking quadratic time. > > > Speaking of inessential but very useful things, I'm also a big fan of > the tuple swap... > a = 2 > b = 3 > (a, b) = (b, a) > print a # 3 > print b # 2
You can also do a list swap. py> a = 4 py> b = 2 py> [a, b] = [b, a] py> a 2 py> b 4 -- http://mail.python.org/mailman/listinfo/python-list