Re: why cannot assign to function call
- From: Steven D'Aprano <steven@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 07 Jan 2009 02:25:21 GMT
On Tue, 06 Jan 2009 13:43:01 -0800, Aaron Brady wrote:
I think one of the ideas we have trouble communicating is that [1, 2, 3]
and [4, 5, 6] can be the same object
Not at the same time they can't.
(using '[:]='), but [1, 2, 3] and [1, 2, 3] don't have to be.
I don't think this is hard to get across, if you think about objects.
You have a list. It's like a box. That box can hold items 1, 2 and 3. You
can replace those items with 4, 5 and 6, and it's still the same box.
Likewise, you can have a box with items 1, 2 and 3 inside it, and a
different box also with items 1, 2 and 3, and they're still different
boxes.
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.
--
Steven
.
- Follow-Ups:
- Re: why cannot assign to function call
- From: Mark Wooding
- Re: why cannot assign to function call
- References:
- Re: why cannot assign to function call
- From: Derek Martin
- Re: why cannot assign to function call
- From: Marc 'BlackJack' Rintsch
- Re: why cannot assign to function call
- From: Grant Edwards
- Re: why cannot assign to function call
- From: Derek Martin
- Re: why cannot assign to function call
- From: Grant Edwards
- Re: why cannot assign to function call
- From: Derek Martin
- Re: why cannot assign to function call
- From: Steven D'Aprano
- Re: why cannot assign to function call
- From: Mark Wooding
- Re: why cannot assign to function call
- From: Aaron Brady
- Re: why cannot assign to function call
- Prev by Date: Re: Oh! The people of all over the world!
- Next by Date: message of Exception
- Previous by thread: Re: why cannot assign to function call
- Next by thread: Re: why cannot assign to function call
- Index(es):
Relevant Pages
|