Is there swap function in Python?

Just just at xs4all.nl
Sun Apr 6 16:23:46 EDT 2003


In article <b6q1so$1cm2$1 at mail.cn99.com>, "Xin Liu" <lx1978 at 263.net> 
wrote:

> >
> > What do you mean by the swap function? What should it do
> > precisely?
> >
> > -- 
> > René Pijlman
> It is a function like swap(a, b) . Use to swap the value of a and b.
> A example in C++ language maybe like:
> template <class T> void swap(T & a, T & b)
> {
>     T * tmp;
>     tmp = a;
>     a = b;
>     b = tmp;
>     return
> }

Try

   b, a = a, b

Just




More information about the Python-list mailing list