0

This question has been answered severally but no application has fixed it for me. I have class a, b and c, I initialize a variable in class a, i want to reassign the value in class b and call the new value in class c. My code is too long to copy it entirely, but this is where the logic is not adding up. Why am i not getting output as John, only ''

a.py

location = ''
username = ''

b.py

import overall

self.spinnertext = "John"
overall.username = self.spinnertext

c.py

import overall

#Set the username
uname = overall.username
print(uname)
Johnn Kaita
  • 432
  • 1
  • 3
  • 13
  • You have no guarantee that the code in `b` will be called from `c` – Lescurel Oct 29 '20 at 09:46
  • Imports are cached upon import. In your `c.py` you will have state of `a.py` at the moment import and it doesn't matter what happens to it after that in `b.py`. You could try to do `importlib.reload()` See this post: https://stackoverflow.com/questions/437589/how-do-i-unload-reload-a-python-module – go2nirvana Oct 29 '20 at 09:59

0 Answers0