why cannot assign to function call

Joe Strout joe at strout.net
Tue Jan 6 11:01:31 EST 2009


Mark Wooding wrote:

> Derek Martin <code at pizzashack.org> wrote:
> 
>> I think I have though, not that it matters, since that was never
>> really my point.  Python's assignment model requires more explanation
>> than the traditional one, simply to state what it does.  That alone is
>> evidence (but not proof).
> 
> Hmm.  Actually, it's not the assignment model which is strange at all.
> It's the data model.  What does an expression like
> 
>   [1, 2, 3]
> 
> denote?  Is it the list itself, or a /reference/ to the list?  If you
> answer the first, you'll want Tcl/C/Fortran semantics.  If you answer
> the second, you'll want Lisp/Python/Javascript semantics.  If you answer
> `it depends', you'll want to be confused.

Well said!

You can easily see that assignment in Python is perfectly ordinary, by 
comparing it to languages that have both values and references (such as 
C++, Java, or REALbasic).  Those languages have only one assignment 
model, that operates on both values and references just fine.

Python has only references, and I think it's for this reason that some 
people here try to pretend that it doesn't have them at all, thus 
leading them to weird explanations of strange assignment and 
argument-passing behavior.

> Python decided that all values are passed around as and manipulated
> through references.  (There are no locatives: references are not values,
> and you can't have a reference to a reference.)

Also very clearly put.

If you don't mind, I may crib some of your verbage for 
<http://www.strout.net/info/coding/valref/>, as it may be clearer than 
my own.

Best,
- Joe






More information about the Python-list mailing list