Finding the instance reference of an object

Gabriel Genellina gagsl-py2 at
Tue Oct 28 06:28:16 CET 2008

En Tue, 28 Oct 2008 00:58:10 -0200, greg <greg at>  

> Steven D'Aprano wrote:
>> By common usage and technical definition, C is call by value. Argument  
>> passing in Python does not behave like C. So why insist that Python is  
>> also call by value?
> Whether it behaves like C is not the test.
> Let's look at the definitions of the terms:
> (1) Call by value: The actual parameter is an expression. It is
>      evaluated and the result is assigned to the formal parameter.
>      Subsequent assignments to the formal parameter do not affect
>      the actual parameter.
> (2) Call by reference: The actual parameter is an lvalue. The
>      formal parameter becomes an alias for the actual parameter,
>      so that assigning to the formal parameter has the same
>      effect as assigning to the actual parameter.
> Seems to me that (1) describes exactly how parameter passing
> works in Python. So why insist that it's *not* call by value?

Those definitions are only applicable to unstructured, primitive types,  
where the only relevant operations are "get value" and "assign value".
Structured types provide other operations too - like selection (attribute  
get/set in Python). It is unspecified on both definitions above what  
happens in those cases. Other posts in this same thread showed that Python  
behaves similarly to call-by-reference in C++ with regard to data members  
inside a structure (that is, mutable objects *can* be changed, and the  
caller sees the change). Combined with your previous conclusion that  
Python implements call-by-value, one should finally conclude that it can't  
be neither cbv nor cbr - it's a different thing.
The term "call by object" was coined in the late '70s to describe this  
behavior. More info about this ever-recurring topic can be found at

Gabriel Genellina

More information about the Python-list mailing list