Skip to main content

logo

Downloads Downloads codecov Hits-of-Code Test-Package Python versions PyPI version Checked with mypy Ruff

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)

Source distribution for contextif 0.0.5
File Size Uploaded
contextif-0.0.5.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for contextif 0.0.5
File Interpreter ABI Platform
contextif-0.0.5-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page