Python dotenv introduction and tutorial

Storing important data in environment variables is a common practice when developing, not only to avoid accidentally committing important data into the codebase, but also to use environment variables to store system or program settings. It is also often used in practice to separate development environment from production environment, for example:

if os. getenv('MODE') == 'development':
    # do development-related things
    # do production-related things

But as the number of environment variables to be set increases, it may lead to a lot of environment variables to be filled every time you do development. If you have encountered such a situation, why not give python-dotenv a try!

Last updated on  Mar 13, 2023  in  Useful Python Modules  by  Amo Chen  ‐ 2 min read