Passing address of variables...
Emile van Sebille
emile at fenx.com
Sat Sep 15 15:34:06 EDT 2001
Pass in a mutable object.
>>> a = []
>>> def f(lst):
... lst.append('len=%s' % len(lst))
...
>>> f(a)
>>> f(a)
>>> a
['len=0', 'len=1']
HTH,
--
Emile van Sebille
emile at fenx.com
---------
"Adonis Vargas" <deltapigz at telocity.com> wrote in message
news:iTNo7.3261$s6.653961 at newsrump.sjc.telocity.net...
> how am i able to pass the address of a variable to another variable have
it
> affected by
> change(s)?
>
> i.e. like in C/C++ you have:
>
> int something(int &blah)
> {
> blah++;
> }
>
> int x=0;
> something(x)
> print x // returns 1
>
> just a rough idea; can this be done in Python?
>
> any help would greatly be appreciated.
>
> Adonis
>
>
More information about the Python-list
mailing list