Closures in leu of pointers?
Michael Torrie
torriem at gmail.com
Sat Jun 29 09:56:31 EDT 2013
On 06/29/2013 05:44 AM, cts.private.yahoo at gmail.com wrote:
> Alas, one reason it's a weak workaround is that it doesn't work - at least, not how I wish it would:
>
>
> $ cat ptrs
>
> x = 34
>
> def p1 (a1):
>
> a1[0] += 12
>
> p1 ([x])
>
> print (x)
>
> $ python ptrs
> 34
you'll have to use it more like this (and also changing your names to be
a bit more sane):
x = [ 34, ]
def test_func( out ):
out[0] += 12
test_func(x)
print (x)
More information about the Python-list
mailing list