expandvars
Expand system variables Unix style
Decision gist · record as of 2026-08-14
Yes. expandvars is a lightweight, dependency-free utility with permissive licensing and no known vulnerabilities. It solves a real problem—flexible environment variable expansion in config files—more elegantly than os.path.expandvars. Aging maintenance is not a concern for a stable, narrow-scope tool. Install if you need bash-style variable syntax in configuration or string interpolation.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.6.2 or later.
- Low install friction with no runtime dependencies.
- Aging maintenance status (336 days since last release) but repository remains active with recent commits; stable for a utility of this scope.
License · maintenance · safety
permissive license (permissive) — MIT License permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
last release 2025-09-12 (336 days) · last repo commit 2025-12-17 · 33 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 3,450,744 downloads/mo, #2,619 on PyPI
Alternatives
Verify before relying
from expandvars import expandvars
result = expandvars("$PATH:${HOME:?}/bin:${UNDEFINED:-/default}")
print(result)- Whether the package handles all edge cases in production config-file parsing workflows.
- Performance characteristics when expanding very large strings or deeply nested variables.
What it is and what it does
expandvars is a Python module that parses and expands environment variable references in strings using bash-like syntax. It goes beyond Python's built-in os.path.expandvars by supporting advanced features: default values (${VAR:-default}), error-on-undefined (${VAR:?}), variable indirection (${!VAR}), and strict mode (nounset=True). It has no runtime dependencies and is designed primarily for reading configuration files that need flexible environment variable interpolation.
The module copies most common bash behaviors but does not attempt full bash compliance—for example, it does not support arrays. You can customize the variable symbol, escape character, and expansion data via the lower-level expand() function. It also respects an EXPANDVARS_RECOVER_NULL environment variable to temporarily disable strict parsing in testing scenarios.
Use it for
- Parse TOML or INI config files that reference environment variables with fallback defaults.
- Build file paths dynamically by expanding $HOME, $PATH, and custom environment variables in application startup.
- Validate that required environment variables are set before running a service, using ${VAR:?} syntax.
- Substitute secrets and credentials from environment into configuration templates without hardcoding.
- Support nested variable references where one env var points to the name of another to resolve.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
expandvars is a lightweight, dependency-free utility with permissive licensing and no known vulnerabilities. It solves a real problem—flexible environment variable expansion in config files—more elegantly than os.path.expandvars. Aging maintenance is not a concern for a stable, narrow-scope tool. Install if you need bash-style variable syntax in configuration or string interpolation.
Install
expandvars on PyPI
Before you install
Low install friction with no runtime dependencies. Aging maintenance status (336 days since last release) but repository remains active with recent commits; stable for a utility of this scope.
Requires Python 3.6.2 or later.
License in practice
MIT License permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
from expandvars import expandvars
result = expandvars("$PATH:${HOME:?}/bin:${UNDEFINED:-/default}")
print(result)
Verify before relying
- Whether the package handles all edge cases in production config-file parsing workflows.
- Performance characteristics when expanding very large strings or deeply nested variables.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.6.2 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Aging 336 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,450,744 / month, #2,619 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: Other AudienceLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: MacOSOperating System :: MicrosoftOperating System :: POSIXOperating System :: UnixProgramming Language :: Python :: 3Topic :: Software DevelopmentTopic :: Utilities |
Evidence: expandvars-1.1.2-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “unix style variable expansion”
- expandvarsExpands Unix-style variable references in strings with bash-like…
- poxPox provides utilities for filesystem exploration, environment…
- parameter-expansion-patchedExpands POSIX and Bash shell parameter syntax in Python strings…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also envsubst · parameter-expansion-patched · bracex · uri-template · pox · braceexpand · environs · contractions · poetry-dotenv-plugin · xonsh