why cannot assign to function call

Steve Holden steve at holdenweb.com
Wed Jan 7 00:19:11 EST 2009


Mark Wooding wrote:
> 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.
> 
Thanks for nailing that one. I have long felt the semantics of Python
could be but poorly served without the use of the term "reference" (and
indeed I have pointed out int he past that the language reference manual
feels free to use the term liberally), but I wasn't able to persist long
enough to bring the conversation to this conclusion (except that I am
pretty sure this *won't* be a conclusion ;-)

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list