why cannot assign to function call

Mark Wooding mdw at distorted.org.uk
Wed Jan 7 04:49:02 CET 2009


Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au> wrote:

> The only tricky thing is that items 1, 2 and 3 can be inside two 
> different boxes at the same time. There's no obvious real world analogy 
> to that without the boxes being nested. This ability for objects to be in 
> two places at once (or even to be inside themselves!) is one of the few 
> reasons why Python's use of references in the implementation needs to be 
> mentioned.

Ahh.  So it /does/ need to be mentioned after all.  But you're wrong:
it's not an implementation detail: it's an essential part of the
language semantics.

A better analogy.  The objects are scattered across the floor.  No
object is contained in another.  However, we have a plentiful supply of
bits of string, each of which is tied to a Teflon-covered paperweight at
one end and has a blob of Blu-Tack on the other.  Instead of putting
something in a box directly, what we do is grab a piece of string, stick
the Blu-Tack to the thing, and put the paperweight in the box.  This
way, we can stick several bits of string to the same object and put the
paperweights in different boxes.  Indeed, nothing stops us sticking two
bits of string to a box, and putting both paperweights inside that same
box.  But fitting a box into itself twice requires origami skills that
frighten me.

The Teflon stops the Blu-Tack from sticking to the paperweights, 'cos
you're not allowed to do that.  

There's a daemon who comes around periodically and cleans up the mess of
paperweights which aren't in boxes, and tidies away things which don't
have any string stuck to them any more, but really he's just an
implementation detail and you wouldn't need him if your floor was big
enough and you had enough bits of sufficiently long string.

-- [mdw]



More information about the Python-list mailing list