Closed
Description
Following my statement in issue #284 that importing is not working and @pfalcon's reply that it is (apropos #282), I decided to write a simple test case to show my findings.
I am basing my test case on the assumption that an import
call will look inside the following two folders on the micropython chip:
/
/SRC
Case 1
- Firstly, I have just downloaded and compiled the latest version of the code.
- I then created the following simple main.py file which I saved in the
/SRC
folder.
MAIN.PY
v1
counter = 0
def addition(a,b):
return a+b
if __name__ == "__main__":
while True:
print(counter)
counter = addition(counter,1)
pyb.delay(1000)
Using:
minicom -D /dev/ttyACM0
I see a nice, steady counter printout to the console 👍
Case 2
- I then created a second .py file which I also saved in the
/SRC
folder
test_module.py
def addition(a,b):
return a+b
and modified main.py to look like this:
MAIN.PY
v2
import test_module
#from test_module import addition
counter = 0
if __name__ == "__main__":
while True:
print(counter)
counter = test_module.addition(counter,1)
#counter = addition(counter,1)
pyb.delay(1000)
which resulted in no compilation error and no counter printout to the minicom console 👎 .
From the commented out code you will see that I also tried the format
from <module_name> import <function>
and it also didn't work.
Am I not understanding something or is it just not working?