Effective constant management tools
Project description
Const-Utils
const-utils is a small-yet-effective library that offers some
tools for working with Python constants. Its main feature is
the Constant Class, which includes utilities for accessing
constants, stored within a container class.
Defining constant classes is available by using ConstClassMeta
(as a metaclass), or the standard BaseConstClass (by inheritance).
Examples
Creating a constant class
class CountryConsts(BaseConstClass):
US = 'United States of America'
UK = 'United Kingdom'
Access options
Access from the class itself
>>> CountryConsts.as_dict() # {'US': 'United States of America', 'UK': 'United Kingdom'}
>>> CountryConsts['US'] # 'United States of America
>>> Country.const_names # ['US, 'UK']
>>> Country.const_values # ['United States of America', 'United Kingdom']
Access global/local constants
>>> # Access current global/local constants (depends on kwarg `local`)
>>> # as a dictionary of names to values
>>> access_namespace_consts(local=False)
Storing class constants to a namespace
>>> # Store constants in a module
>>> CountryConsts.apply_to_module('some_module_name', override=True)
>>> # Store constants as globals
>>> CountryConsts.apply()
>>> # Store constants as locals
>>> CountryConsts.apply(local=True)
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 const_utils-0.0.1.tar.gz.
File metadata
- Download URL: const_utils-0.0.1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8f7a932c1f3f3bfb152f3d69c2c50400428615a8e534e62f0021bfec5521d43
|
|
| MD5 |
8a5ab2c29e8847ecd498f734433001bf
|
|
| BLAKE2b-256 |
ae43150e7fd983a32d7dbd24d2c6df55c41e6e3022127a6af25c1f5e3fc44617
|
File details
Details for the file const_utils-0.0.1-py3-none-any.whl.
File metadata
- Download URL: const_utils-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f5f87a9068b60486eba9e44182d7f5165f655c15e743e514704cd5c4483e499
|
|
| MD5 |
1e7ac6a621c75e37dac07d1eec239b7f
|
|
| BLAKE2b-256 |
fe83d7baa046bab289d0e4e0f35b46d6d489bee970e128115949ec596720d666
|