I'm using an object's __del__()
to unsubscribe it from an event (using an event scheme similar to this):
import my_enviroment
class MyClass():
def __del__(self):
my_environment.events.my_event -= self.event_handler_func
Oddly I received the following error at the end of the program's run:
Exception AttributeError: "'NoneType' object has no attribute 'events'" in <bound method MyClass.__del__ of <myclass.MyClass instance at 0x04C54580>> ignored
How could this be possible?! my_environment
is a module I imported, how come it could be None? (events
is a global object in it with event hooks such as my_event
)