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"
2
  • It would be better if you add your code by editing your question. Commented Jan 23, 2014 at 12:25
  • Can anybody tell me how can edit the global variable during runtime Commented Jan 23, 2014 at 12:43

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.