On Feb 27, 5:02 pm, Tamer Higazi <[EMAIL PROTECTED]> wrote:
> Hi!
> Can somebody of you make me a sample how to define a function based on
> "call by reference" ???
>
> I am a python newbie and I am not getting smart how to define functions,
> that should modify the variable I passed by reference.
>
> thanks in advance
>
> Tamer

def my_func(x):
    x[0] = 4


my_list = [3]
print my_list

my_func(my_list)
print my_list

--output:--
[3]
[4]



class MyData(object):
    pass

def another_func(obj):
    obj.val += 10


md = MyData()
md.val = 20
another_func(md)
print md.val

--output:--
30
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to