contextif: run the function only in a specific context
Sometimes we may need to run a function only if it happens in a strictly defined context. In this case, we can use this mini library.
Install it:
pip install contextif
And use:
from contextif import state
with state:
state(print, 'hello,', 'world!') # It will be printed.
state(print, "it's me, Mario!") # It won't.
Using state as a function, you can pass another function and arguments to it there. It will be called only if it happens in a context created also using state. The function will not be called out of context.
For convenience, after the first import of state, this variable becomes builtin and you can access it in other modules of your program without importing.
Metadata
Release files for contextif 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| contextif-0.0.5.tar.gz | 3.9 kB | Without provenance | Details for contextif-0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| contextif-0.0.5-py3-none-any.whl | Python 3 | none | any | Details for contextif-0.0.5-py3-none-any.whl |
Total release size: 8.1 kB
Release files / contextif-0.0.5.tar.gz
| Download URL | contextif-0.0.5.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
927b7dc0b39945137dba63581416ca3c3ccb28ab2d49d61e30d386ae7d7732b7
|
|
BLAKE2b-256 checksum How to use checksums |
86a09c607b4b15f77f224e3b43dd38014cd43c8c21db701dd990f318db32ffda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / contextif-0.0.5-py3-none-any.whl
| Download URL | contextif-0.0.5-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
402ddae000fc743eafd9fbba2b4b2e70df2d18883a238731981532a6c4a9ea15
|
|
BLAKE2b-256 checksum How to use checksums |
c85663bc357e214e429aa44716da395575e84ba23f363a042e6234401015d659
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for contextif 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.