why cannot assign to function call

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Thu Jan 8 02:45:35 EST 2009


On Wed, 07 Jan 2009 10:17:55 +0000, Mark Wooding wrote:

> Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au> wrote:
> 
>> Only in the sense that the behaviour of *real world* objects don't
>> entirely match the behaviour of Python objects. If you just accept that
>> Python objects can be in two places at once, an unintuitive concept I
>> accept but hardly difficult to grasp, then you don't need to mention
>> references.
> 
> To my mind, explaining that objects can actually be in two (or three, or
> any unbounded number) of places at once, stashed inside each other to an
> arbitrary degree -- that looks like the excuses of someone who's been
> caught in a lie.  Maybe it was a useful lie-to-children, meant to avoid
> explaining the full details in advance, but the time comes to put away
> childish things, and learn the truth.  (I can't believe I just quoted
> Paul.  I feel all dirty.)

All analogies are lies-to-children. I don't think this is any worse than 
the lie-to-children about magic pieces of string that you can only handle 
by the paperweight at one end. Both analogies contain leaky abstractions.


> The `they're just objects' model is very simple, but gets tied up in
> knots explaining things.  The `it's all references' model is only a
> little more complicated, but explains everything.

But it *over* explains, because it implies things that "everybody knows" 
about references in other languages that aren't true for Python. 

Of course it's not literally true that "everybody knows" that you can use 
references to implement a swap(x, y) procedure. But people coming from a 
C or Pascal background tend to assume that everything is like C/Pascal, 
and there are a lot of them. If C was a rare, unfamiliar language, my 
opposition to using the term "reference" would be a lot milder. Maybe in 
another five years?


> No, indeed.  Python is a language for talking about paperweights.  And
> it's because of the paperweights that the duck-typing works: all the
> paperweights are the same shape and size, so they're physically
> interchangeable.

Okay, the abstraction has leaked again... are the paperweights references 
to the objects, or the names we've bound objects to? I'm confused...

How do we deal with anonymous objects in your model?




-- 
Steven



More information about the Python-list mailing list