Skip to main content

Python events handling, C# style

Project description

Axel is a very small Python library inspired by C# events that allows an easy and elegant events handling.


from axel import Event

event = Event()
def on_event(*args, **kwargs):
    return (args, kwargs)

event += on_event                     #handler registration
print(event(10, 20, y=30))
>> ((True, ((10, 20), {'y': 30}), <function on_event at 0x00BAA270>),)

event -= on_event                     #handler is unregistered
print(event(10, 20, y=30))
>> None

class Mouse(object):
    def __init__(self): = Event(self) += self.on_click   #handler registration

    def on_click(self, sender, *args, **kwargs):
        assert isinstance(sender, Mouse), 'Wrong sender'
        return (args, kwargs)

mouse = Mouse()
print(, 20))
>> ((True, ((10, 20), {}),
>>  <bound method Mouse.on_click of <__main__.Mouse object at ...>>),) -= mouse.on_click         #handler is unregistered
print(, 20))
>> None


- handlers can receive the sender as their first argument
- handlers can be executed in the same or separate threads
- handlers may be executed synchronous or asynchronous
- handlers execution may be synchronized on a lock
- the time allocated for the execution of a handler is controllable
- the number of actively executed handlers at one time is controllable
- the execution result of a handler can be cached
- the result of the execution is provided as a tuple ((flag, result, handler),)
- in case of error, the traceback may be provided for each handler in error


Erwin Mayer <traderwin at gmail dot com>
Rob van der Most <Rob at rmsoft dot nl>

Please see the documentation:

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for axel, version 0.0.7
Filename, size File type Python version Upload date Hashes
Filename, size axel-0.0.7-py3-none-any.whl (8.1 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page