What event system for Python do you use? I'm already aware of pydispatcher, but I was wondering what else can be found, or is commonly used?
I'm not interested in event managers that are part of large frameworks, I'd rather use a small bare-bones solution that I can easily extend.
Here is a minimal design that should work fine. What you have to do is to simply inherit
Observer
in a class and afterwards useobserve(event_name, callback_fn)
to listen for a specific event. Whenever that specific event is fired anywhere in the code (ie.Event('USB connected')
), the corresponding callback will fire.Example: