0

I am trying to use the prefix modl and iterate through .py files that I use as settings. I'd like to stick to python files because it is easy to declare functions and variables and import them. The problem I run into is that the module does not update at the second iteration:

for settingsfile in ['settings1.py', 'settings2.py']:
    modl = importlib.import_module(settingsfile)
    var1 = modl.var1
    print('the variable:', var1)

output:

the variable:var1_from_settings1
the variable:var1_from_settings1
2
  • I think you should try without adding the extention .py to your setting files. Commented Nov 3, 2023 at 23:19
  • What are the contents of settings1.py and settings2.py? Commented Nov 3, 2023 at 23:36

0

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.