A simple global value manager
Project description
RegisterValue
A lightweight Python library that uses the Singleton pattern to create a RegisterValue class for storing specific values, such as configuration parameters or other values used in multiple places. The value can be accessed by importing the package, eliminating the need to repeatedly pass parameters, thus reducing code complexity.
Installation
pip install register-value
Qiuck Start
# register value
from register_value import register_value as rv
rv.register('key', 'value')
# access value
from register_value import register_value as rv
value = rv.get('key')
Application
Considering that we have two files, main.py and fun.py.
main.py
from register_value import register_value as rv
from fun import get_lr
rv.register('lr', 0.01)
print(f'lr: {get_lr()}')
fun.py
from register_value import register_value as rv
def get_lr():
return rv.get('lr')
As we can see, in the fun.py, we get parameter lr through the register_value package, instead of passing it as a parameter. This will simplify the code specially in the huge project.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file register_value-0.0.1.tar.gz.
File metadata
- Download URL: register_value-0.0.1.tar.gz
- Upload date:
- Size: 1.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6e8b0572e3b949d6c25846e3862c24c0b78ec2099825d473f6562721838ce3f
|
|
| MD5 |
8c68744a860be810889272412e073381
|
|
| BLAKE2b-256 |
c1bcd673515539dc4e7b8a8d22a6ea9de312096cc0ede13e2e9f34c28102dc36
|
File details
Details for the file register_value-0.0.1-py3-none-any.whl.
File metadata
- Download URL: register_value-0.0.1-py3-none-any.whl
- Upload date:
- Size: 2.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93531f7a2f8200b7f7c9cf1874801c6e85c2d2b4bab2d5d8fe10094a49047a92
|
|
| MD5 |
5c864dc8cb65ea866f40346863bc2362
|
|
| BLAKE2b-256 |
32b25a19473d1d3ccf876df0e214e1b1dec3a16dd1051be60fc870e0969f6618
|