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.
Documentation
Installation
$ pip install resumeback
Example Usage
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()
Development
Requires Python, poetry, and GNU Make.
Use make help to show the available targets.
poetry is used for dependency and virtualenv management.
tox is used as a test runner for multiple isolated environments.
flake8 is used for code linting.
Github Actions are used for CI.
Acknowledgements
Project started initially after a forum post from @Varriount on the Sublime Text forum. I just took his idea “to the next (abstraction) level” and made it more convenient to use.
Metadata
Release files for resumeback 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| resumeback-1.0.0.tar.gz | 11.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| resumeback-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.0 kB
Release files / resumeback-1.0.0.tar.gz
| Download URL | resumeback-1.0.0.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3c02156eea168e1e3b5306d4b40accd289e71520a4d2575ddfeaa476ce02c092
|
|
BLAKE2b-256 checksum How to use checksums |
c8b6501b60165044caa8dfca86380797e71f85900cd49dc9dd1e0f0d1a63ad98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.8.2 Linux/5.0.0-1032-azure
|
Release files / resumeback-1.0.0-py3-none-any.whl
| Download URL | resumeback-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f2046ce1df7fe096d938b1c3babb1ec9e9b8aab8f2d92213f376bba80ffcc24
|
|
BLAKE2b-256 checksum How to use checksums |
3e5c00ba8fbebf0bde564525dc2551ee5a843f0e4d27311f52dad95164edede5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.8.2 Linux/5.0.0-1032-azure
|