Is there swap function in Python?

Ian Bicking ianb at
Sun Apr 6 22:05:41 CEST 2003

On Sun, 2003-04-06 at 14:56, Xin Liu wrote:
> I know it is a too sample question. I can't find anything in my python
> documents about the swap funtion. Of cause, I can write a swap use boost or
> an other way. But the language has grown for 13 years. Why not its library
> include a so basic funtion?

Do you mean, to swap two variables?  You do it like:

a, b = b, a

More information about the Python-list mailing list