========
backcall
========
.. image:: https://travis-ci.org/takluyver/backcall.png?branch=master
:target: https://travis-ci.org/takluyver/backcall
Specifications for callback functions passed in to an API
If your code lets other people supply callback functions, it's important to
specify the function signature you expect, and check that functions support that.
Adding extra parameters later would break other peoples code unless you're careful.
backcall provides a way of specifying the callback signature using a prototype
function::
from backcall import callback_prototype
@callback_prototype
def handle_ping(sender, delay=None):
# Specify positional parameters without a default, and keyword
# parameters with a default.
pass
def register_ping_handler(callback):
# This checks and adapts the function passed in:
callback = handle_ping.adapt(callback)
ping_callbacks.append(callback)
If the callback takes fewer parameters than your prototype, *backcall* will wrap
it in a function that discards the extra arguments. If the callback expects
more arguments, a TypeError is thrown when it is registered.
For more details, see the `docs <http://backcall.readthedocs.org/en/latest/>`_ or
the `Demo notebook <http://nbviewer.ipython.org/github/takluyver/backcall/blob/master/Demo.ipynb>`_.
The tests are run with `pytest <http://pytest.org/latest/>`_. In the root directory,
execute::
py.test
Raw data
{
"_id": null,
"home_page": "https://github.com/takluyver/backcall",
"name": "backcall",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Thomas Kluyver",
"author_email": "thomas@kluyver.me.uk",
"download_url": "https://files.pythonhosted.org/packages/a2/40/764a663805d84deee23043e1426a9175567db89c8b3287b5c2ad9f71aa93/backcall-0.2.0.tar.gz",
"platform": "",
"description": "========\nbackcall\n========\n\n.. image:: https://travis-ci.org/takluyver/backcall.png?branch=master\n :target: https://travis-ci.org/takluyver/backcall\n\nSpecifications for callback functions passed in to an API\n\nIf your code lets other people supply callback functions, it's important to\nspecify the function signature you expect, and check that functions support that.\nAdding extra parameters later would break other peoples code unless you're careful.\n\nbackcall provides a way of specifying the callback signature using a prototype\nfunction::\n\n from backcall import callback_prototype\n \n @callback_prototype\n def handle_ping(sender, delay=None):\n # Specify positional parameters without a default, and keyword\n # parameters with a default.\n pass\n \n def register_ping_handler(callback):\n # This checks and adapts the function passed in:\n callback = handle_ping.adapt(callback)\n ping_callbacks.append(callback)\n\nIf the callback takes fewer parameters than your prototype, *backcall* will wrap\nit in a function that discards the extra arguments. If the callback expects\nmore arguments, a TypeError is thrown when it is registered.\n\nFor more details, see the `docs <http://backcall.readthedocs.org/en/latest/>`_ or\nthe `Demo notebook <http://nbviewer.ipython.org/github/takluyver/backcall/blob/master/Demo.ipynb>`_.\n\nThe tests are run with `pytest <http://pytest.org/latest/>`_. In the root directory,\nexecute::\n\n py.test\n",
"bugtrack_url": null,
"license": "",
"summary": "Specifications for callback functions passed in to an API",
"version": "0.2.0",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "4671e998e1853d64a365680de7ecc7a2",
"sha256": "fbbce6a29f263178a1f7915c1940bde0ec2b2a967566fe1c65c1dfb7422bd255"
},
"downloads": -1,
"filename": "backcall-0.2.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "4671e998e1853d64a365680de7ecc7a2",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 11157,
"upload_time": "2020-06-09T15:11:30",
"upload_time_iso_8601": "2020-06-09T15:11:30.870875Z",
"url": "https://files.pythonhosted.org/packages/4c/1c/ff6546b6c12603d8dd1070aa3c3d273ad4c07f5771689a7b69a550e8c951/backcall-0.2.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "1f4c9a370c78743406296f48e56e8821",
"sha256": "5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e"
},
"downloads": -1,
"filename": "backcall-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "1f4c9a370c78743406296f48e56e8821",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 18041,
"upload_time": "2020-06-09T15:11:32",
"upload_time_iso_8601": "2020-06-09T15:11:32.931736Z",
"url": "https://files.pythonhosted.org/packages/a2/40/764a663805d84deee23043e1426a9175567db89c8b3287b5c2ad9f71aa93/backcall-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-06-09 15:11:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "takluyver",
"github_project": "backcall",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "backcall"
}