Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
backcall/ | H | 03-May-2022 | - | 937 | 656 | |
docs/ | H | 03-May-2022 | - | 516 | 230 | |
tests/ | H | 03-May-2022 | - | 42 | 30 | |
.gitignore | H A D | 31-Dec-2017 | 102 | 14 | 10 | |
.travis.yml | H A D | 09-Jun-2020 | 228 | 17 | 12 | |
Demo.ipynb | H A D | 31-Dec-2017 | 7.3 KiB | 267 | 267 | |
LICENSE | H A D | 31-Dec-2017 | 1.5 KiB | 28 | 22 | |
PKG-INFO | H A D | 01-Jan-1970 | 226 | 8 | 7 | |
README.rst | H A D | 31-Dec-2017 | 1.5 KiB | 41 | 29 | |
pyproject.toml | H A D | 09-Jun-2020 | 489 | 17 | 15 | |
setup.py | H A D | 01-Jan-1970 | 495 | 21 | 14 |
README.rst
1======== 2backcall 3======== 4 5.. image:: https://travis-ci.org/takluyver/backcall.png?branch=master 6 :target: https://travis-ci.org/takluyver/backcall 7 8Specifications for callback functions passed in to an API 9 10If your code lets other people supply callback functions, it's important to 11specify the function signature you expect, and check that functions support that. 12Adding extra parameters later would break other peoples code unless you're careful. 13 14backcall provides a way of specifying the callback signature using a prototype 15function:: 16 17 from backcall import callback_prototype 18 19 @callback_prototype 20 def handle_ping(sender, delay=None): 21 # Specify positional parameters without a default, and keyword 22 # parameters with a default. 23 pass 24 25 def register_ping_handler(callback): 26 # This checks and adapts the function passed in: 27 callback = handle_ping.adapt(callback) 28 ping_callbacks.append(callback) 29 30If the callback takes fewer parameters than your prototype, *backcall* will wrap 31it in a function that discards the extra arguments. If the callback expects 32more arguments, a TypeError is thrown when it is registered. 33 34For more details, see the `docs <http://backcall.readthedocs.org/en/latest/>`_ or 35the `Demo notebook <http://nbviewer.ipython.org/github/takluyver/backcall/blob/master/Demo.ipynb>`_. 36 37The tests are run with `pytest <http://pytest.org/latest/>`_. In the root directory, 38execute:: 39 40 py.test 41