The 'events' library for Python, currently at version 0.5, aims to bring the elegance of C# EventHandler to Python. It provides a simple, lightweight mechanism for event subscription and firing, encapsulating the core functionality for attaching and invoking callback functions (event handlers) in sequence, thus facilitating event-driven programming patterns in a straightforward manner. The library is considered mature and stable, with its last release in July 2023, and sees infrequent updates.
pip install eventsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to create an `Events` object, subscribe multiple callback functions using `+=`, fire events, and unsubscribe callbacks using `-=`.
Ensure `event_instance.event_name -= handler_function` is called when the handler is no longer required or the associated object is being disposed of. Consider weak references for advanced scenarios if manual unsubscription is problematic.
To enforce predefined events, subclass `Events` and list event names in the class definition, or pass an iterator of event names to the `Events` constructor. Attempts to subscribe to or fire an undefined event will then raise an `EventsException`.
Always import explicitly (e.g., `from events import Events`) and check the `events.__file__` to confirm you're using the correct package. Refer to documentation specific to `github.com/pyeve/events`.
Install the library using pip: `pip install Events`. Ensure your import statement is `from events import Event`.
Access event data using `event.sender`, `event.args`, or `event.kwargs`. If you intend to pass named data, use keyword arguments when firing the event and access them via `event.kwargs['your_key']`.
Ensure that the event handler function's parameters (`sender`, `*args`, `**kwargs`) correctly correspond to the arguments passed to `event.fire(sender, *args, **kwargs)`.
No dependency data recorded yet.