On Tue, 2018-08-14 at 10:55 -0400, Dennis Lee Bieber wrote:
> On Tue, 14 Aug 2018 06:18:41 -0700 (PDT), skybuck2...@hotmail.com declaimed
> the following:
> 
> > On Monday, August 13, 2018 at 10:01:37 PM UTC+2, Léo El Amri wrote:
> > > On 13/08/2018 21:54, skybuck2...@hotmail.com wrote:
> > > > I just had a funny idea how to implement a swap operator for types:
> > > > 
> > > > A >< B
> > > > 
> > > > would mean swap A and B.
> > > 
> > > I think that:
> > > 
> > > a, b = b, a
> > > 
> > > is pretty enough
> > 
> > LOL.
> > 
> > A >< B is shorter !
> > 
> 
>       But is specific to swapping just two entities...
> 
>       c, a, b = a, b, c
> 
> moves three entities at once -- and can be expanded for more.
> 
> > > > a = 1
> > > > b = 2
> > > > c = "confusion"
> > > > 
> > > > c, a, b = a, b, c
> > > > print a
> 
> 2
> > > > print b
> 
> confusion
> > > > print c
> 
> 1
Indeed, that is elegant.  It doesn't take a special knowledge of syntax, for 
good guessers. It also doesn't look like two male variables peeing on each 
others feet.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to