Skip to main content

Bringing the elegance of C# EventHanlder to Python

https://secure.travis-ci.org/nicolaiarocci/events.png?branch=master

The C# language provides a handy way to declare, subscribe to and fire events. Technically, an event is a “slot” where callback functions (event handlers) can be attached to - a process referred to as subscribing to an event. Here is a handy package that encapsulates the core to event subscription and event firing and feels like a “natural” part of the language.

>>> def something_changed(reason):
...     print "something changed because %s" % reason
...

>>> from events import Events
>>> events = Events()
>>> events.on_change += something_changed

Multiple callback functions can subscribe to the same event. When the event is fired, all attached event handlers are invoked in sequence. To fire the event, perform a call on the slot:

>>> events.on_change('it had to happen')
'something changed because it had to happen'

Documentation

Complete documentation is available at http://events.readthedocs.org

Installing

Events is on PyPI so all you need to do is:

pip install events

Testing

Just run:

python setup.py test

The package has been tested under Python 2.6, Python 2.7 and Python 3.3.

License

Events is BSD licensed. See the LICENSE for details.

Contributing

Please see the Contribution Guidelines.

Attribution

Based on the excellent recipe by Zoran Isailovski, Copyright (c) 2005.

Release files for Events 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Events 0.1.0
File Size Uploaded
Events-0.1.0.tar.gz 4.6 kB Details

Release files / Events-0.1.0.tar.gz

Download URL Events-0.1.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e79f6a4580ac68bb8ad48865b995bfabd1b8b75aa491a31f9c15880b58cd6208
BLAKE2b-256 checksum
How to use checksums
573783fec80f3115a44b5c52ca292efbce58c844a35b6079913ac9a0fb2b915a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page