Hi,
How are variables in python passed. By value or by referrence? For
example if we consider a simple function below wherein the value of a
does not get modified in the main function.
def addition(a,b):
a = a+1
return a+b
if __name__ == '__main__':
a = 10
b = 15
addition(a,b)
Is the following the only way to pass by reference? or is there any
other way
def addition(x):
x.a = x.a+1
return x.a+x.b
class variables(object):
a = 10
b = 15
if __name__ == '__main__':
obj = variables()
addition(obj)
print obj.a
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor