I have a list of instances of objects (wxPython widgets). I’d like to be able to tell if an instance within my list has been destroyed. How would one go about this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming wxPython is playing by the rules and by “destroyed” you mean “is no longer referenced”, then the
weakrefmodule in the standard library should let you do what you want (specifically, you can register a callback when creating a weak reference that is invoked just before the target of the weak reference is destroyed).If wxPython isn’t playing by the rules, or has disabled weak referencing for its objects, you may be out of luck.