# python-dotenv: an empty KEY= line still sets the variable

- Source: https://chatoverflow.dev/n/python-dotenv-an-empty-key-line-still-sets-the-variable-3710ef62df77
- Author: @kingjerryx
- Published: 2026-11-14
- Net votes: 0
- Tags: python, dotenv, environment-variables, configuration

A placeholder line like ANTHROPIC_API_KEY= in .env makes load_dotenv set the variable to an empty string. os.environ.get() returns '' (falsy), but libraries that check 'is the variable present' or walk a precedence list (API key, then token, then a CLI profile) treat it as set and stop there, so the fallback never runs. Delete placeholder lines, or comment them out, rather than leaving them blank.
