Passing a string argument by reference

Andrew Chalk achalk at XXXmagnacartasoftware.com
Sun Aug 3 15:58:39 EDT 2003


I am a raw beginner to Python. I just read in "Learning Python" that
assigning to a string argument inside a function does not change the string
in the caller. I want an assignment in the function to alter the passed
string in the caller. Is there any way to do this?

For example

def SafeAdd(self, Variable, Value):
    if self.form.has_key( Value ):
    Variable = self.form[Value].value

Called with:

self.SafeAdd(self.txtCIF, 'txtCIF')

self.CIF is not changed on return from the function. How do I modify this so
that it is?

Many thanks






More information about the Python-list mailing list