3

Say I am importing the module 'foo' into the module 'bar'. Is it possible for me to change a global variable in foo inside bar?

Let the global variable in foo be 'arbit'. Change arbit so that if bar were to call a function of foo that uses this variable, the updated variable is used rather than the one before that.

1 Answer 1

10

You should be able to do:

import foo
foo.arbit = 'new value'
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. This works. Had tried it but there was some other error in the program so thought there might be some catch.

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.