On Thu, Sep 25, 2008 at 8:03 AM, Steve Collins <[EMAIL PROTECTED]> wrote:

> that's what I was trying (incorrectly) to achieve the above example.
> but how can I do this for an arbitrary number of objects in a list?
>
> I have a list x = [a,b,c] and a list y = [d,e,f], both filled with
> instance objects.

Note that lists don't contain objects, they contain references to objects.

> I want the instance at x[n] to reference the
> instance at y[n]

This doesn't really make sense, if x[n] and y[n] are the same type of
object. You can have x[n] and y[n] reference the same object, or you
can have them reference different objects with the same value.

> n = 0
> while n < range(len(x))
> x[n] = y[n]
> n+=1

That seems to do what you want. After this loop, x[n] and y[n] will
refer to the same object. How is it not?

I think you still misunderstand what objects and lists and references
are, and this misunderstanding is making it hard to for me to
understand what you are really trying to accomplish. Perhaps you can
give a slightly longer example with real classes and lists, perhaps
one that doesn't do what you want, and we can correct it.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to