Serdar Tumgoren wrote:
In Python, if you have x[0] = Dummy(), the list object x stores the Dummy
instance itself.
I think the above example gets to the source of my confusion. Clearly the
instance remains accessible via x[0], but I somehow never thought of a
specific list index as an obvious
First off, thanks for the detailed response! I had a few follow-up questions
below, if you're willing to indulge. Feel free to direct me to RTM some
books on C and the python source code, of course :)
> Why? Because the designer of Python, Guido van Rossum, wanted it to be
> possible, and he desi
Serdar Tumgoren wrote:
But I think I see your point. The list object behaves the same as the
objects stored inside the list.
Er, surely not... the list object is a list, the objects inside the list
are ints. They do not behave the same.
> In other words, the list object is a
reference to
Serdar Tumgoren wrote:
Hi folks,
I'm trying to gain a deeper understanding of why it's possible to modify
list elements in-place *without* replacing them. For instance, why is the
below possible?
Why? Because the designer of Python, Guido van Rossum, wanted it to be
possible, and he designed t
>
>
> Would you have the same question about what takes place here?:
>
> >>> list_ = [3,4,5]
> >>> list_[1] = 10
> >>> list_
> [3, 10, 5]
> >>>
>
>
No surprise there. It's a familiar usage and it appears to be the canonical
example (in textbooks/tuts) for demonstrating "in-place" object
modificatio
On Thu, Nov 11, 2010 at 06:02, Serdar Tumgoren wrote:
> Hi folks,
> I'm trying to gain a deeper understanding of why it's possible to modify
> list elements in-place *without* replacing them. For instance, why is the
> below possible?
>
class Dummy(object):
> ... pass
> ...
a = Dummy
Hi folks,
I'm trying to gain a deeper understanding of why it's possible to modify
list elements in-place *without* replacing them. For instance, why is the
below possible?
>>> class Dummy(object):
... pass
...
>>> a = Dummy()
>>> b = Dummy()
>>> x = [a, b]
# modify list elements in-place
>>>