how to get the ordinal number in list

Tim Chase python.list at tim.thechases.com
Mon Aug 11 08:30:04 EDT 2014


On 2014-08-11 07:55, Roy Smith wrote:
> > A C programmer asked to swap variables x and y, typically writes
> > something like
> > 
> > t = x; x = y; y = t;
> > 
> > Fine, since C cant do better.  
> 
> Sure C can do better.
> 
> x = x ^ y
> y = y ^ x
> x = x ^ y
> 
> Any self-respecting C hacker would write it this way :-)

Pish, such redundancy...everyone knows a C programmer would write
that as

 x ^= y
 y ^= x
 x ^= y

:-)

-tkc






More information about the Python-list mailing list