0

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"))?

sundowatch
  • 3,012
  • 3
  • 38
  • 66
  • Why not just set `config = Config(RepositoryEnv('../.env'))`, instead of introducing a new `envFile` variable? – larsks Mar 15 '21 at 23:16
  • @larsks sorry for my poor python knowledge. Is it acceptable to define this name to a variable? – sundowatch Mar 15 '21 at 23:35
  • You can create your own variable named `config` rather than importing it from the `decouple` module. You can name variables pretty much anything you want, with the exception of a few language keywords. – larsks Mar 15 '21 at 23:38
  • Thank you. Please write it as answer – sundowatch Mar 15 '21 at 23:43
  • I believe this is actually a duplicate of another question. I think you'll find some answers there that will be helpful. – larsks Mar 15 '21 at 23:52

0 Answers0