1

While running a code in python I want to update a dictionary value that is in config(global variable) I'm trying to do but i got the following error.

config.py

survey={'url':''}

runnigcode.py

url=config.__getattribute__(config.environment)
url['url']='myurl.com'

TypeError: "'module' object does not support item assignment"
Steinar Lima
  • 7,644
  • 2
  • 39
  • 40

1 Answers1

0

in your runningcode.py, just import the variable as a method:

from config import survey

print survey

if you want to modify the value in the config.py, just use write method, like in this post: Edit configuration file through python

Community
  • 1
  • 1
peluzza
  • 329
  • 2
  • 4
  • 11