🔐 python-decouple: Clean and Safe Configs with .env
Hardcoding secrets or config values in your Python code?
Stop doing that. python-decouple is a dead-simple way to keep your configuration clean, secure, and environment-specific.
✅ Why use it?
Load values from a
.envfile or environment variablesKeep secrets out of version control
Cast types automatically (
str,int,bool, etc.)
🧪 Example
pythonCopyEdit# config.py
from decouple import config
DEBUG = config("DEBUG", default=False, cast=bool)
DB_URL = config("DATABASE_URL")
And in your .env file:
iniCopyEditDEBUG=True
DATABASE_URL=postgresql://user:pass@localhost:5432/dbname
🧼 Simple, readable, and safe
Use it in any Python project — even without frameworks.
It’s great for scripts, CLI tools, microservices, or anything that needs clean configs.