Library for using callbacks to resume your code.
A Python library for using callbacks to resume your code.
resumeback provides a utility function decorator that enables using callback-based interfaces in a single line of execution – a single function.
$ pip install resumeback
from threading import Thread from resumeback import send_self def ask_for_user_input(question, on_done): def watcher(): result = input(question) on_done(result) Thread(target=watcher).start() @send_self def main(this): # "this" is a reference to the created generator instance arbitrary_value = 10 # Yield pauses execution until one of the generator methods is called, # such as `.send`, which we provide as the callback parameter. number = yield ask_for_user_input("Please enter a number", this.send) number = int(number) print("Result:", number * arbitrary_value) if __name__ == "__main__": main()
Requires Python, poetry, and GNU Make.
Use make help to show the available targets.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size resumeback-1.0.0-py3-none-any.whl (6.4 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size resumeback-1.0.0.tar.gz (11.5 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for resumeback-1.0.0-py3-none-any.whl