[Tutor] passing by reference
steve at pearwood.info
Sun Mar 13 14:06:56 CET 2011
Vineeth Mohan wrote:
> How are variables in python passed. By value or by referrence?
What makes you think that value and reference are the only two choices?
See this Wikipedia article for a list of at least a dozen different
argument passing techniques:
Three months ago I answered a similar question. You could do worse than
> Is the following the only way to pass by reference? or is there any
> other way
To mimic the behaviour of pass-by-reference, it is more common to pass a
>>> def modify(arg):
... arg = 23
>>> var = 
>>> assert var == 23
but using instance attributes also works.
More information about the Tutor