I have 2 extremely simple python files. I am doing this as a test to see if blah2.py sees the updated version of the two variables initially declared as None after the 2 second sleep. The files are as below:
blah1.py
from time import sleep
import blah2
movingVariable1 = None
movingVariable2 = None
sleep(2)
movingVariable1 = "sup"
movingVariable2 = "blahhh"
blah2.myFunc()
blah2.py
from blah1 import movingVariable1
from blah1 import movingVariable2
def myFunc():
global movingVariable1
global movingVariable2
print(movingVariable1)
print(movingVariable2)
I am getting the following error though, and I'm not sure why.
Traceback (most recent call last):
File "blah1.py", line 2, in <module>
import blah2
File "/home/pi/blah2.py", line 1, in <module>
from blah1 import movingVariable1
File "/home/pi/blah1.py", line 10, in <module>
blah2.myFunc()
AttributeError: module 'blah2' has no attribute 'myFunc'
myFunc() clearly is defined as a function though in blah2.py. Can anyone explain what I am doing wrong in this basic example?