2011/11/14 Богун Дмитрий <vuglu...@vugluskr.org.ua>: > m = master() > s = m.slave() > s.master is m >
Can you simply have m.slave() pass a parameter to the slave's constructor? class Master(object): class Slave(object): def __init__(self,master): self.master=master print 'Slave.__init__: self.master: ', self.master def slave(self): return self.Slave(self) Alternatively, you don't have to nest the classes at all: class Slave(object): def __init__(self,master): self.master=master print 'Slave.__init__: self.master: ', self.master class Master(object): def slave(self): return Slave(self) By passing 'self' to the Slave() constructor, I give the slave a chance to keep a reference to its own master. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list