r/Python • • 21m ago

Discussion what's your setup for config across dev and prod in a small python project?

i keep going back and forth between a .env file loaded with python-dotenv, a pydantic settings class, and plain os.environ lookups. for a small project with one dev and one prod environment, what has actually held up for you? mostly curious how you deal with secrets and defaults without it turning into a mess after a year.

1 Upvotes

1 comment sorted by

•

u/christian-mq 11m ago

For a small project my approach has always been a .env with dotenv. I do, however, prefer my prod config not to be saved in a place inaccessible (like GitHub secrets) - this would depend on your ci/cd though. If using AWS or GCP I prefer to keep the prod vars in a secret vault - using these you can, with a correctly permissioned account, retrieve the .env file back with your secrets. It is a pain to loose a secret in GitHub and have noway to retrieve it.