Skip to main content

Python Wires

Project description

PyPI CI Status Test Coverage Documentation

Python Wires is a library to facilitate callable wiring by decoupling callers from callees. It can be used as a simple callable-based event notification system, as an in-process publish-subscribe like solution, or in any context where 1:N callable decoupling is appropriate.

Installation

Python Wires is a pure Python package distributed via PyPI. Install it with:

$ pip install wires

Quick Start

Create a Wires object:

from wires import Wires

w = Wires()

Its attributes are callables, auto-created on first access, that can be wired to other callables:

def say_hello():
    print('Hello from wires!')

w.my_callable.wire(say_hello)       # Wires `w.my_callable`, auto-created, to `say_hello`.

Calling such callables calls their wired callables:

w.my_callable()                     # Prints 'Hello from wires!'

More wirings can be added:

def say_welcome():
    print('Welcome!')

w.my_callable.wire(say_welcome)     # Wires `w.my_callable` to `say_welcome`, as well.
w.my_callable()                     # Prints 'Hello from wires!' and 'Welcome!'.

Wirings can also be removed:

w.my_callable.unwire(say_hello)     # Removes the wiring to `say_hello`.
w.my_callable()                     # Prints 'Welcome!'

w.my_callable.unwire(say_welcome)   # Removes the wiring to `say_welcome`.
w.my_callable()                     # Does nothing.

To learn more about Python Wires, including passing parameters, setting wiring limits and tuning the call-time coupling behaviour, please refer to the remaining documentation at https://python-wires.readthedocs.org/.

Thanks

About

Python Wires was created by Tiago Montes.

Project details


Download files

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

Source Distribution

wires-19.2.0.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

wires-19.2.0-py2.py3-none-any.whl (10.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file wires-19.2.0.tar.gz.

File metadata

  • Download URL: wires-19.2.0.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

File hashes

Hashes for wires-19.2.0.tar.gz
Algorithm Hash digest
SHA256 7a59c8fbca9190b801bed6f24ff10e3e187decedc554ac6632487df5c7803bc8
MD5 fa0bfbe5669151ae1cc5a43a05d7b745
BLAKE2b-256 85574d0f749b92a6d5fac2ea7b31d203c6b336a5359a38e52ba676cb6ee4f7e2

See more details on using hashes here.

File details

Details for the file wires-19.2.0-py2.py3-none-any.whl.

File metadata

  • Download URL: wires-19.2.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

File hashes

Hashes for wires-19.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 824304ff866cd7b8d336c83de31c2f1ab117af0a0f0951e98a29740854ab517c
MD5 b0e5009256e4e5f938d70832a3e30859
BLAKE2b-256 463a054cae776f06175d6c7ebdd1c40f7fe297dc720a826f865522945d71fe8d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page