lzconfig — Lazy Configuration without instantiation
lz: Too lazy to type
lazy
Import and go. No init, no loader calls, no boilerplate.
import lzconfig
# Attribute-style access
print(lzconfig.database.host) # → "localhost"
print(lzconfig.database.credentials.user) # → "admin"
# Dict-style access
print(lzconfig['database']['host']) # → "localhost"
# Mixed access
print(lzconfig.database['port']) # → 5432
# Safe access with defaults
print(lzconfig.get('debug', False)) # → True
How It Works
At import time, lzconfig discovers your config file, parses it, interpolates
environment variables, and replaces itself in sys.modules with the loaded
configuration object. From then on, lzconfig is your config.
Config File Resolution
-
If
LZCONFIG_FILEis set (and non-empty), that file is used. Relative paths are resolved against the current working directory. -
Otherwise, the current directory is scanned for the first match:
Priority Filename 1 lzconfig.yaml2 lzconfig.yml3 lzconfig.json4 lzconfig.toml5 lzconfig.ini6 lzconfig.cfg7 lzconfig.env8 lzconfig.xml -
If nothing is found,
ConfigNotFoundErroris raised at import time.
Supported Formats
| Format | Extensions |
|---|---|
| YAML | .yaml .yml |
| JSON | .json |
| TOML | .toml |
| INI | .ini .cfg |
| .env | .env |
| XML | .xml |
All formats work out of the box — no extras needed.
Environment Variable Interpolation
$VAR and ${VAR} references in config values are expanded at load time
using os.path.expandvars:
# lzconfig.yaml
database:
host: $DB_HOST
password: ${DB_PASSWORD}
Undefined variables are left as literal text — no error is raised.
Access Patterns
| Pattern | Example |
|---|---|
| Attribute chain | lzconfig.a.b.c |
| Dict chain | lzconfig['a']['b']['c'] |
| Mixed | lzconfig.a['b'].c |
| List index | lzconfig['items'][0].name |
| Membership | 'key' in lzconfig |
| Safe get | lzconfig.get('key', default) |
| Keys | lzconfig.keys() |
| Length | len(lzconfig) |
| Iteration | for k in lzconfig: ... |
Key / Method Collision
If a config key happens to have the same name as a ConfigObject method
(e.g., get, items, keys):
- Attribute access (
lzconfig.items) returns the method. - Dict access (
lzconfig['items']) always returns the config value.
This is a deliberate trade-off. When in doubt, use [] — it always works.
Error Handling
| Exception | When |
|---|---|
ConfigNotFoundError |
No config file found at import time |
ConfigParseError |
File found but cannot be parsed |
ConfigKeyError |
Accessing a non-existent key |
All exceptions inherit from ConfigError and can be imported directly:
from lzconfig import ConfigError, ConfigNotFoundError, ConfigKeyError
License
MIT
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 lzconfig-0.1.1.tar.gz.
File metadata
- Download URL: lzconfig-0.1.1.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b18ae4ed3cd2a5a9b52fc53feba261c555affb06de69ec537ea08db031a90883
|
|
| MD5 |
cb62c31edd78f734abbd2b3086d29828
|
|
| BLAKE2b-256 |
8cdafbfcc45298c2ffcc25848ca6c15e998f1faab900d1b960d6040f336da2e6
|
Provenance
The following attestation bundles were made for lzconfig-0.1.1.tar.gz:
Publisher:
publish.yml on SihanLv/lzconfig
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lzconfig-0.1.1.tar.gz -
Subject digest:
b18ae4ed3cd2a5a9b52fc53feba261c555affb06de69ec537ea08db031a90883 - Sigstore transparency entry: 2292143282
- Sigstore integration time:
-
Permalink:
SihanLv/lzconfig@20a8c5773fddbb87ae7b6df01727accd5fde8b94 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/SihanLv
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@20a8c5773fddbb87ae7b6df01727accd5fde8b94 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lzconfig-0.1.1-py3-none-any.whl.
File metadata
- Download URL: lzconfig-0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2397e59db9fa47b40ec69c5c6adaed55eb560668dc47bae2c4d6f5776e990597
|
|
| MD5 |
c8b31720683132419e3f56aaebb836de
|
|
| BLAKE2b-256 |
aedfc119175dbe952e5753772b39eaf68ec0c09ab026857a8d02efe6b3295290
|
Provenance
The following attestation bundles were made for lzconfig-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on SihanLv/lzconfig
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lzconfig-0.1.1-py3-none-any.whl -
Subject digest:
2397e59db9fa47b40ec69c5c6adaed55eb560668dc47bae2c4d6f5776e990597 - Sigstore transparency entry: 2292143287
- Sigstore integration time:
-
Permalink:
SihanLv/lzconfig@20a8c5773fddbb87ae7b6df01727accd5fde8b94 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/SihanLv
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@20a8c5773fddbb87ae7b6df01727accd5fde8b94 -
Trigger Event:
push
-
Statement type: