reference or pointer to some object?

Steven Bethard steven.bethard at gmail.com
Wed Jan 12 19:43:28 EST 2005


Jeff Shannon wrote:
> Torsten Mohr wrote:
> 
>> I still wonder why a concept like "references" was not
>> implemented in Python.  I think it is (even if small)
>> an overhead to wrap an object in a list or a dictionary.
> 
> Because Python uses a fundamentally different concept for variable names 
> than C/C++/Java (and most other static languages).  In those languages, 
> variables can be passed by value or by reference; neither term really 
> applies in Python.  (Or, if you prefer, Python always passes by value, 
> but those values *are* references.)  Python doesn't have lvalues that 
> contain rvalues; Python has names that are bound to objects.  Passing a 
> parameter just binds a new name (in the called function's namespace) to 
> the same object.

Point of clarification: Java objects (but not Java primitive types like 
ints or doubles) work almost identically to Python objects -- you can 
basically think of them as references being passed by value.  There's no 
way to pass by reference in Java (even for Java primitive types).

Steve



More information about the Python-list mailing list