>
>
> 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
modification. In these examples the object being modified is the list
itself, rather than the objects stored in the list. The examples typically
show how the sort function sorts the actual list as opposed to returning a
sorted copy of the list.

But I think I see your point. The list object behaves the same as the
objects stored inside the list. In other words, the list object is a
reference to an ordered sequence of object references, and you're operating
on those (referenced) objects rather than copies of the objects when you
iterate over the list. Is that correct? If so, no doubt there's a simpler
way to say all that?
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to