On 17/01/24 4:00 am, Chris Angelico wrote:
class Form:
     def __init__(self):
         self.elements = []

class Element:
     def __init__(self, form):
         self.form = form
         form.elements.append(self)

If you make the reference from Element to Form a weak reference,
it won't keep the Form alive after it's been closed.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to