Multi-dimensional list initialization

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Nov 7 00:05:34 EST 2012


On Wed, 07 Nov 2012 00:23:44 +0000, MRAB wrote:

>> Incorrect.  Python uses what is commonly known as call-by-object, not
>> call-by-value or call-by-reference.  Passing the list by value would
>> imply that the list is copied, and that appends or removes to the list
>> inside the function would not affect the original list.  This is not
>> what Python does; the list inside the function and the list passed in
>> are the same list.  At the same time, the function does not have access
>> to the original reference to the list and cannot reassign it by
>> reassigning its own reference, so it is not call-by-reference semantics
>> either.
>>
> I prefer the term "reference semantics".


Oh good, because what the world needs is yet another name for the same 
behaviour.

- call by sharing
- call by object sharing
- call by object reference
- call by object
- call by value, where "values" are references 
  (according to the Java community)
- call by reference, where "references" refer to objects, not variables
  (according to the Ruby community)
- reference semantics


Anything else?

http://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing




-- 
Steven



More information about the Python-list mailing list