Can global variable be passed into Python function?
steve+comp.lang.python at pearwood.info
Sat Feb 22 09:28:17 CET 2014
On Sat, 22 Feb 2014 19:10:02 +1100, Chris Angelico wrote:
> On Sat, Feb 22, 2014 at 7:02 PM, <wxjmfauth at gmail.com> wrote:
>>>>> # a swapping variant
>>>>> def swap(a, b):
>> ... ab = [a, b]
>> ... ab, ab = ab, ab
>> ... return ab, ab
> Provably identical to:
> def swap(a, b):
> return b, a
> The rest is just fluff.
You don't even need the function call.
a, b = b, a
More information about the Python-list