{ "info": { "author": "FichteFoll", "author_email": "fichtefoll2@googlemail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "============\n resumeback\n============\n\n.. image:: https://travis-ci.org/FichteFoll/resumeback.svg\n :target: https://travis-ci.org/FichteFoll/resumeback\n\n.. image:: https://coveralls.io/repos/FichteFoll/resumeback/badge.svg\n :target: https://coveralls.io/github/FichteFoll/resumeback?branch=master\n\n.. image:: https://img.shields.io/pypi/v/resumeback.svg\n :target: https://pypi.python.org/pypi/resumeback\n\n.. image:: https://img.shields.io/pypi/pyversions/resumeback.svg\n :target: https://pypi.python.org/pypi/resumeback/\n\n.. .. image:: https://img.shields.io/pypi/dd/resumeback.svg\n.. :target: https://pypi.python.org/pypi/resumeback/\n\nA Python library for using callbacks to resume your code.\n\n``resumeback`` provides a utility function decorator\nthat enables using callback-based interfaces\nin **a single line of execution**\n-- a single function.\n\nFull docs are available here: http://fichtefoll.github.io/resumeback/\n\n\nInstallation\n============\n\n.. code-block:: shell\n\n $ pip install resumeback\n\n\nUsage\n=====\n\n``resumeback.send_self``'s mechanic of sending a generator function\na handle to itself\nis what allows for better flow control\nusing callback-based interfaces.\nEssentially, it enables *a single line of execution*.\n\nFollowing is a function that uses an asynchronous callback mechanism\nto signal that user input has been made:\n\n.. code-block:: python\n\n from threading import Thread\n\n def ask_for_user_input(question, on_done):\n def watcher():\n result = input(question)\n on_done(result)\n\n Thread(target=watcher).start()\n\nThe *traditional* way of using a function like ``ask_for_user_input`` would be\nto define a function of some way,\neither as a closure or using ``functools.partial`` so that we can preserve\nthe state we already accumulated prior to executing said function.\n\nFor example like so:\n\n.. code-block:: python\n\n def main():\n arbitrary_value = 10\n\n def on_done(number):\n number = str(number)\n print(\"Result:\", number * arbitrary_value)\n\n ask_for_user_input(\"Please enter a number\", on_done)\n\nBecause Python does not have multi-line inline functions,\nthis is rather awkward,\nbecause we are jumping from the function call of ``ask_for_user_input``\nback to our previously defined function ``on_done``\n-- which is only ever going to be called once in this context.\n\nHowever, using ``resumeback.send_self``,\nwe can do something to *flatten our line of execution*\nby passing a callback to resume execution in our original function:\n\n.. code-block:: python\n\n from resumeback import send_self\n\n @send_self\n def main():\n this = yield # \"this\" is now a reference to the just-created generator\n arbitrary_value = 10\n\n # Yield pauses execution until one of the generator methods is called,\n # such as `.send`, which we provide as the callback parameter.\n number = yield ask_for_user_input(\"Please enter a number\", this.send)\n number = str(number)\n print(\"Result:\", number * arbitrary_value)\n\n\nAcknowledgements\n================\n\nProject started initially after a `forum post`__ from `@Varriount`__\non the Sublime Text forum.\nI just took his idea \"to the next (abstraction) level\"\nand made it more convenient to use.\n\n__ http://www.sublimetext.com/forum/viewtopic.php?f=6&t=17671\n__ https://github.com/Varriount", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://fichtefoll.github.io/resumeback/", "keywords": "generator,resume,callback", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "resumeback", "package_url": "https://pypi.org/project/resumeback/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/resumeback/", "project_urls": { "Homepage": "http://fichtefoll.github.io/resumeback/" }, "release_url": "https://pypi.org/project/resumeback/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "Library for using callbacks to resume your code.", "version": "0.1.0" }, "last_serial": 1854724, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "77f1ea015d8c0cac02d1caf194c95494", "sha256": "f8c7e8e2e33b1bdbbd6b2f8657fcea3321bdd8d32a55cc314eba2ccf54959680" }, "downloads": -1, "filename": "resumeback-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "77f1ea015d8c0cac02d1caf194c95494", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8535, "upload_time": "2015-12-10T00:56:36", "url": "https://files.pythonhosted.org/packages/9f/db/42c4b45e79f9aed8f3badd951f4d9298b3aac38c106467eca734636a2712/resumeback-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "253165baaf5ef5843c199a0c063d0b1e", "sha256": "17613f66543f295e971964744a83d078df94e49d9133773b6ffa050d1806f509" }, "downloads": -1, "filename": "resumeback-0.1.0.zip", "has_sig": false, "md5_digest": "253165baaf5ef5843c199a0c063d0b1e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11510, "upload_time": "2015-12-10T00:56:44", "url": "https://files.pythonhosted.org/packages/20/a9/e038931b1e6817a38a0f1790adf96daa980ba4562739aa0ecfeb82e54271/resumeback-0.1.0.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "77f1ea015d8c0cac02d1caf194c95494", "sha256": "f8c7e8e2e33b1bdbbd6b2f8657fcea3321bdd8d32a55cc314eba2ccf54959680" }, "downloads": -1, "filename": "resumeback-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "77f1ea015d8c0cac02d1caf194c95494", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8535, "upload_time": "2015-12-10T00:56:36", "url": "https://files.pythonhosted.org/packages/9f/db/42c4b45e79f9aed8f3badd951f4d9298b3aac38c106467eca734636a2712/resumeback-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "253165baaf5ef5843c199a0c063d0b1e", "sha256": "17613f66543f295e971964744a83d078df94e49d9133773b6ffa050d1806f509" }, "downloads": -1, "filename": "resumeback-0.1.0.zip", "has_sig": false, "md5_digest": "253165baaf5ef5843c199a0c063d0b1e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11510, "upload_time": "2015-12-10T00:56:44", "url": "https://files.pythonhosted.org/packages/20/a9/e038931b1e6817a38a0f1790adf96daa980ba4562739aa0ecfeb82e54271/resumeback-0.1.0.zip" } ] }