On 4/14/05, Rich Krauter <[EMAIL PROTECTED]> wrote: > Maybe you could use a factory. It would allow you to simplify your Node > class, and encapsulate the instantiation behavior you want outside the > class.
Thanks for the suggestion; I think that's what I'll do. On 4/14/05, Max Noel <[EMAIL PROTECTED]> wrote: > Well, if you want b and a to refer to the same object, just use b = a. If you'll look at my code, you'll see that I *did* try that approach, and it did not persist past __init__ for some reason: class Node: ... def __init__(self, cargo=None, prev=None, next=None, nod=False): """x.__init__(...) initializes x; see x.__class__.__doc__ for signature""" if not isinstance(cargo, Node) or nod: self.cargo = cargo self.prev = prev self.next = next else: ################################# self = cargo ## see? ################################# print id(self), id(cargo) print self.cargo >>> a = Node(1) >>> b = Node(a) 12932600 12932600 1 >>> id(b) 12960632 -- Email: singingxduck AT gmail DOT com AIM: singingxduck Programming Python for the fun of it. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor