Environment Variable
A variable defined in the operating system environment or in a .env file. It stores settings and secrets without embedding them in the code.
Example
# .env
API_KEY=sk-abc123
BATCH_SIZE=50
import os
key = os.environ['API_KEY']
Why
- secrets do not end up in the code and repository;
- settings can be changed without modifying the code;
- convenient for different environments (dev, prod).