parameter-expansion-patched
raw JSON → 0.3.1 verified Fri May 01 auth: no python
A Python library that implements shell-style parameter expansion (e.g., ${VAR:-default}, ${VAR#prefix}). It is a patched fork of the original parameter-expansion library, maintained for PyPI distribution. Current version 0.3.1, with occasional updates.
pip install parameter-expansion-patched Common errors
error ModuleNotFoundError: No module named 'parameter_expansion' ↓
cause Importing the old package name instead of the patched version.
fix
Install parameter-expansion-patched and import from parameter_expansion_patched.
error AttributeError: 'ParameterExpander' object has no attribute 'expand' ↓
cause Using the class from the original unpatched library which has a different API.
fix
Ensure you are using parameter_expansion_patched (version 0.3.1) and that the class has an 'expand' method.
Warnings
gotcha The expander does NOT access the actual OS environment by default. You must pass a dict or use os.environ explicitly. Failing to do so may lead to empty expansions. ↓
fix If you want to use the real environment, pass os.environ: ParameterExpander(env=os.environ).
gotcha The library only supports a subset of shell parameter expansion features. Known missing: ${!indirect}, ${parameter:offset:length}, ${parameter/pattern/string} substitution. ↓
fix Check the documentation for supported syntax before relying on advanced patterns.
Imports
- ParameterExpander wrong
from parameter_expansion import ParameterExpandercorrectfrom parameter_expansion_patched import ParameterExpander
Quickstart
from parameter_expansion_patched import ParameterExpander
expander = ParameterExpander(env={'USER': 'alice', 'HOME': '/home/alice'})
result = expander.expand('Hello ${USER:-default}, your home is ${HOME}')
print(result) # Hello alice, your home is /home/alice