Skip to main content

A universal mixin to add on(), off(), and trigger() style event handling to any Python class.

Project description

onoff is a Python module that provides the OnOffMixin class which can be used to add on(), off(), and trigger() style events to any Python class.

Note

Example

>>> from onoff import OnOffMixin
>>> class Foo(OnOffMixin):
...     def __init__(self):
...         self.on("hello", self.hello)
...     def hello(self, *args):
...         print("Hello: %s" % args)
...     def test(self, *args):
...         self.trigger("hello", *args)
...
>>> f = Foo()
>>> f.test("Triggered events rock!")
Hello: Triggered events rock!

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 onoff, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size onoff-1.0.1.tar.gz (13.5 kB) File type Source Python version None 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 Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page