Pass variable by reference
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue May 6 21:18:15 EDT 2014
On Tue, 06 May 2014 15:16:54 -0400, Terry Reedy wrote:
> On 5/5/2014 8:39 PM, Satish Muthali wrote:
>> Hello experts,
>>
>> I have a burning question on how to pass variable by reference in
>> Python.
>
> Python passes objects to functions. CPython implements this by passing
> object pointers. In one sense, your request is impossible. In another,
> it already happens.
Pass *by* reference is not the same as pass *a* reference. Confusing
variables, values and references to values is how you get Ruby
programmers swearing that Ruby does pass by reference, and Java
programmers swearing that Java does pass by value, for *exactly* the same
behaviour that Python has.
--
Steven D'Aprano
http://import-that.dreamwidth.org/
More information about the Python-list
mailing list