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.
Metadata
Release files for register-value 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 | |
|---|---|---|---|
| register_value-0.0.1.tar.gz | 1.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| register_value-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.2 kB
Release files / register_value-0.0.1.tar.gz
| Download URL | register_value-0.0.1.tar.gz |
|---|---|
| Size | 1.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f6e8b0572e3b949d6c25846e3862c24c0b78ec2099825d473f6562721838ce3f
|
|
BLAKE2b-256 checksum How to use checksums |
c1bcd673515539dc4e7b8a8d22a6ea9de312096cc0ede13e2e9f34c28102dc36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.10.13
|
Release files / register_value-0.0.1-py3-none-any.whl
| Download URL | register_value-0.0.1-py3-none-any.whl |
|---|---|
| Size | 2.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
93531f7a2f8200b7f7c9cf1874801c6e85c2d2b4bab2d5d8fe10094a49047a92
|
|
BLAKE2b-256 checksum How to use checksums |
32b25a19473d1d3ccf876df0e214e1b1dec3a16dd1051be60fc870e0969f6618
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.10.13
|