Does this code create a circular reference ?

Darrell news at dorb.com
Tue Nov 30 16:42:06 EST 1999


Let the child keep a key to look up the parent.

dic={}

 class child:
   def __init__(self, parent):
     self.parent = parent

   def do_something(self):
     pass

 class headache:
    def __init__(self):
        global dic
        dic[`self`]=self

   def method(self):
     a_child = child(`self`)
     a_child.do_something()


--
--Darrell
"Ionel Simionescu" <ionel at psy.uva.nl> wrote in message > I need advice on
whether the situation described below introduces circular
> references.
>







More information about the Python-list mailing list