METADATA 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. Metadata-Version: 2.1
  2. Name: backcall
  3. Version: 0.2.0
  4. Summary: Specifications for callback functions passed in to an API
  5. Home-page: https://github.com/takluyver/backcall
  6. License: UNKNOWN
  7. Author: Thomas Kluyver
  8. Author-email: thomas@kluyver.me.uk
  9. Description-Content-Type: text/x-rst
  10. Classifier: License :: OSI Approved :: BSD License
  11. Classifier: Programming Language :: Python :: 2
  12. Classifier: Programming Language :: Python :: 2.7
  13. Classifier: Programming Language :: Python :: 3
  14. ========
  15. backcall
  16. ========
  17. .. image:: https://travis-ci.org/takluyver/backcall.png?branch=master
  18. :target: https://travis-ci.org/takluyver/backcall
  19. Specifications for callback functions passed in to an API
  20. If your code lets other people supply callback functions, it's important to
  21. specify the function signature you expect, and check that functions support that.
  22. Adding extra parameters later would break other peoples code unless you're careful.
  23. backcall provides a way of specifying the callback signature using a prototype
  24. function::
  25. from backcall import callback_prototype
  26. @callback_prototype
  27. def handle_ping(sender, delay=None):
  28. # Specify positional parameters without a default, and keyword
  29. # parameters with a default.
  30. pass
  31. def register_ping_handler(callback):
  32. # This checks and adapts the function passed in:
  33. callback = handle_ping.adapt(callback)
  34. ping_callbacks.append(callback)
  35. If the callback takes fewer parameters than your prototype, *backcall* will wrap
  36. it in a function that discards the extra arguments. If the callback expects
  37. more arguments, a TypeError is thrown when it is registered.
  38. For more details, see the `docs <http://backcall.readthedocs.org/en/latest/>`_ or
  39. the `Demo notebook <http://nbviewer.ipython.org/github/takluyver/backcall/blob/master/Demo.ipynb>`_.
  40. The tests are run with `pytest <http://pytest.org/latest/>`_. In the root directory,
  41. execute::
  42. py.test