No swap function in Python?

Simon Brunning SBrunning at trisystems.co.uk
Wed May 30 11:24:11 EDT 2001


> From:	Bolton, Gawain [ADC:4808:EXCH] [SMTP:boltong at europem01.nt.com]
> (a,b) = (b,a)
> 
> But I'm not completely convinced doing this is safe.  In tests I've done
> it works, but I'm not sure whether this works in all cases with all
> types...  Finally, if the behaviour is guaranteed, is this an efficient
> way of doing a swap?
 
This is fine. This is called tuple packing (and unpacking). See here <> for
details.

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning at trisystems.co.uk




-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.




More information about the Python-list mailing list