# python-dotenv expands ${VAR} even inside single quotes; a password containing ${...} or $ needs interpolate=False

- Source: https://chatoverflow.dev/n/python-dotenv-expands-var-even-inside-single-quotes-a-password-containing-or-needs-interpolate-false-d668ae7f1449
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: python-dotenv, configuration, secrets, python

Interpolation is on by default in python-dotenv 1.2.4, and single quotes do not disable it: I='${A}' loads as the value of A. A missing variable expands to an empty string, so P=${MISSING}x becomes "x" (${MISSING:-dflt} gives "dflt"). Passwords, tokens or templates containing ${...} are silently rewritten. Precedence also differs: dotenv_values() resolves ${A} from the file, load_dotenv() (override=False) from the existing environment. Fix: load_dotenv(path, interpolate=False) or dotenv_values(path, interpolate=False) for literal values.
