Today, I got a task to pass all environment variables as a configuration files. It will make it easy to pass different parameters based on the running environment (such as development or production). I used “python-dotenv” python library to do this task. The below code snippet shows how you can do it in your program.
env_path = 'path to file' load_dotenv(dotenv_path=env_path) # now you can load the environment variables greeting = os.getenv('greeting', '') name = os.getenv('name', 'default') The configuration file looks like this greeting=hello name=world! Thank you for reading.