function arguments passed by reference

Marcello Pietrobon teiffel at attglobal.net
Wed Mar 3 15:05:19 EST 2004


Hello,

My background is C++

I would like to know for sure if it is possible to pass a value by 
reference to a function AND having it changed by the function itself


def changeValue( text ):
    text = 'c'
    print text
    return

 >>> txt = 'a'
 >>>changeValue( txt )
'c'
 >>>print txt
'a'

Question 1)
I guess that in Python ( differently than in C++)  somehow txt is passed 
by reference even if its value is not changed.
Is this true ?

Question 2)
How can I define a function that changes the value of txt ( without 
having to return the changed value ) ?

Question 3)
Is there some documentation talking extensively about this ?


Thank you,
Marcello






More information about the Python-list mailing list