axel 0.0.3
Python event handling (C# style)
Downloads ↓ | Package Documentation
Axel is a very small Python library inspired by C# events that allows an easy and elegant event handling.
Examples:
from axel import Eventevent = Event()def on_event(*args, **kwargs):return (args, kwargs)event += on_event #handler registrationprint(event(10, 20, y=30))>> ((True, ((10, 20), {'y': 30}), <function on_event at 0x00BAA270>),)event -= on_event #handler is unregisteredprint(event(10, 20, y=30))>> Noneclass Mouse(object):def __init__(self):self.click = Event(self)self.click += self.on_click #handler registrationdef on_click(self, sender, *args, **kwargs):assert isinstance(sender, Mouse), 'Wrong sender'return (args, kwargs)mouse = Mouse()print(mouse.click(10, 20))>> ((True, ((10, 20), {}),>> <bound method Mouse.on_click of <__main__.Mouse object at ...>>),)mouse.click -= mouse.on_click #handler is unregisteredprint(mouse.click(10, 20))>> None
- Features:
- handlers can receive the sender as their first argument
- handlers are always executed in 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 memoized
- 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
Please see the documentation: http://packages.python.org/axel
| File | Type | Py Version | Uploaded on | Size | # downloads |
|---|---|---|---|---|---|
| axel-0.0.3.zip (md5) | Source | 2010-06-29 | 12KB | 737 | |
- Author: Adrian Cristea
- Documentation: axel package documentation
- Keywords: event raise handle
- License: MIT
-
Categories
- Development Status :: 4 - Beta
- Environment :: MacOS X
- Environment :: Other Environment
- Environment :: Plugins
- Environment :: Web Environment
- Environment :: Win32 (MS Windows)
- Intended Audience :: Developers
- Intended Audience :: Education
- Intended Audience :: Information Technology
- Intended Audience :: Other Audience
- License :: OSI Approved :: MIT License
- Operating System :: MacOS
- Operating System :: Microsoft :: Windows
- Operating System :: OS/2
- Operating System :: OS Independent
- Operating System :: POSIX :: Linux
- Operating System :: Unix
- Programming Language :: Python
- Programming Language :: Python :: 2.6
- Programming Language :: Python :: 3
- Programming Language :: Python :: 3.0
- Programming Language :: Python :: 3.1
- Topic :: Education
- Topic :: Internet :: WWW/HTTP
- Topic :: Software Development
- Topic :: Software Development :: Libraries
- Topic :: Software Development :: Libraries :: Python Modules
- Topic :: Utilities
- Package Index Owner: adrian.cristea
- DOAP record: axel-0.0.3.xml
