Skip to main content

ContextManaged Assign

This Python project provides a context manager for temporarily assigning a value to a variable or attribute. The original value is restored when the context is exited.

Usage

from contextmanaged_assign import assign

l = [1, 2, 3]

assert l[0] == 1
with assign("l[0]", 2):
    assert l[0] == 2
assert l[0] == 1

Please note that assign cannot modify local variables themselves. For example, the following code will not work:

x = 1
with assign("x", 2):
    assert x == 2  # AssertionError: 1 != 2
assert x == 1

Installation

Simply install the package using pip:

pip install contextmanaged-assign

Then import the assign function from the contextmanaged-assign module.

License

MIT

Metadata

Release files for contextmanaged-assign 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for contextmanaged-assign 0.1.0
File Size Uploaded Provenance
contextmanaged_assign-0.1.0.tar.gz 2.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for contextmanaged-assign 0.1.0
File Interpreter ABI Platform
contextmanaged_assign-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.5 kB

Release files / contextmanaged_assign-0.1.0.tar.gz

Download URL contextmanaged_assign-0.1.0.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2fb048178836a43313976d9f48d7e444b4d792fa0e1ce6950060419135c7cc1e
BLAKE2b-256 checksum
How to use checksums
73eee6b504910b1ed5df9363492f8bb85ae6f0689da152372542decaa9334f1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / contextmanaged_assign-0.1.0-py3-none-any.whl

Download URL contextmanaged_assign-0.1.0-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e12a26bbe0501dc4b498925dc2bc8b58fcd78fab0e3de1e8b75d822f6683866
BLAKE2b-256 checksum
How to use checksums
183886961657f6c95c41fab88103872bf86b38b7d6bf49d39fe7533152865b4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Security for contextmanaged-assign 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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