How to change .env file path in Python?

46 Views Asked by At

My boss has changed his mind, want me to change .env file path.

We all know we can call .env variable as like this:

from decouple import config

variable_from_env = config('someVariableName')

And I know that we can call .env file outside of root path like this:

from decouple import config, Config, RepositoryEnv

envFile = Config(RepositoryEnv("../.env"))

variable_from_env = envFile('someVariableName')

We'll move the .env file to parent path. But there are so much variables which have called by using config('someVariableName')

Is there any easy way to achive this, or should I use Config(RepositoryEnv("../.env"))?

0

There are 0 best solutions below