Swapping variables with tuple unpacking

Tuple unpacking leads to the beautiful Python idiom for swapping two (or more) variables:

>>> a = 'jelly'
>>> b = 'bean'
>>> a, b = b, a
>>> a
bean
>>> b
jelly
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset