Can global variable be passed into Python function?

wxjmfauth at gmail.com wxjmfauth at gmail.com
Sat Feb 22 03:26:43 EST 2014


Le samedi 22 février 2014 09:10:02 UTC+1, Chris Angelico a écrit :
> 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[1], ab[0] = ab[0], ab[1]
> 
> > ...     return ab[0], ab[1]
> 
> 
> 
> Provably identical to:
> 
> 
> 
> def swap(a, b):
> 
>     return b, a
> 
> 
> 
> The rest is just fluff.
> 
> 
> 
> ChrisA

Right. My bad, (just wake up).

jmf



More information about the Python-list mailing list