TmpVar
TmpVar is used to change the variables environement temprorarily to run some codes and restore the previous environment.
Example
import TmpVar
a = 3
b = 6
c = 9
class TestClass:
def __init__(self, a, b, c) -> None:
self.a = a
self.b = b
self.c = c
d = TestClass(a, b ,c)
print(a, b, c,
d.a, d.b, d.c)
with TmpVar({'d.a':3354}, a=453):
print('—————— temporal environment:——————')
print(a, b, c,
d.a, d.b, d.c)
print('—————— raw environment:——————')
print(a, b, c,
d.a, d.b, d.c)
# 3 6 9 3 6 9
# —————— temporal environment:——————
# 453 6 9 3354 6 9
# —————— raw environment:——————
# 3 6 9 3 6 9
Usage
For single variable, you can simpily run it with:
with TempEnv(varname1=value1, varname2=value2,...):
run some code
...
For attribute of variables, you can use:
with TempEnv('varname1.attribute1=value1', 'varname2.attribute2=value2',...):
run some code
...
For some items in list or dict, I didn't figure out how to access them in proper way.
Metadata
Release files for TmpVar 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| TmpVar-0.0.1.tar.gz | 2.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| TmpVar-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.0 kB
Release files / TmpVar-0.0.1.tar.gz
| Download URL | TmpVar-0.0.1.tar.gz |
|---|---|
| Size | 2.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4f77a026d41ac5f5dafe236c31e492ed73cc767524afca272ae2af990a91c1d8
|
|
BLAKE2b-256 checksum How to use checksums |
e39a02e7907d725ad7762598a701f003e087eb8c713b504c26c30f2093cdbe0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.1
|
Release files / TmpVar-0.0.1-py3-none-any.whl
| Download URL | TmpVar-0.0.1-py3-none-any.whl |
|---|---|
| Size | 2.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27902264619804603448d2715c93ca7f9660491f69793e13beb408f573a33c0c
|
|
BLAKE2b-256 checksum How to use checksums |
854f3ef3974c33998a8dc02e0024dfdeb0070ae44b65f3602bbcd6b3725945eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.1
|