0

i have .env file and I am importing it with:

from dotenv import dotenv_values

config = dotenv_values('{}/.env")

and using this config as **config

But i need to add my key, values in my .env but when I do this the code failt to run. I think this is happening because of the **config

Can someone telling me how can I add my key:value in my .env withou break the code?

khelwood
  • 55,782
  • 14
  • 81
  • 108
pouchewar
  • 399
  • 1
  • 10
  • Are you wondering what ``**config`` does *or* how to fix your problem of having additional keys? – MisterMiyagi Mar 29 '22 at 13:19
  • hey man, both things actually. – pouchewar Mar 29 '22 at 13:20
  • 1
    So, are you adding values in the `.env` file itself, or trying to add values in python? – joanis Mar 29 '22 at 13:21
  • I am adding values to .env file – pouchewar Mar 29 '22 at 13:22
  • `**config` expands that dictionary as if you had specified all those values as parameters. Presumably it's used in a function call like `my_func(**config)`, which will have the effect of passing each key:value pair in `.env` to `my_func()`. – joanis Mar 29 '22 at 13:23
  • Let's backtrack a bit: for a good question, you should show the actual error message, with the full stack trace. – joanis Mar 29 '22 at 13:23
  • 1
    And here I'm going to bet that the value you're trying to add is not accepted by the function you're calling. – joanis Mar 29 '22 at 13:24
  • `**config` by itself is a syntax error, because it's not an expression. It's *only* valid as *part* of the function-call syntax. – chepner Mar 29 '22 at 13:24

0 Answers0