[Tutor] pointers for python?

Thomi Richards thomi at imail.net.nz
Fri Oct 3 20:10:01 EDT 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi all,

In C, you can modify a variable from within a seperate function, by passing a 
pointer to that function. Is there any way to do this in python? it'd be 
kinda useful ;)

I'm sure i read it in the tutorial a while back, but searching the same 
tutorials now, I can't seem to find it anywhere... any ideas?

to clarify, currently, this:

def inc(x):
	x+=1

a=1
inc(a)
print a

prints "1"

is there a way to get the inc() function to modify the original variable, even 
though it's not in the function's scope?


THanks,

- -- 
Thomi Richards,
http://once.sourceforge.net/


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/fg/Z2tSuYV7JfuERAi0jAJ0WsGXRMBGcuUhaVNR2yx7gdWRCnQCgiqce
KED+ZlWXIc+qxewJMdEG+uc=
=o6XS
-----END PGP SIGNATURE-----




More information about the Tutor mailing list