Page 2 of 2

Re: How to include a module

Posted: Tue Mar 17, 2020 9:11 am
by john7
OlivierLenoir wrote:
Tue Mar 17, 2020 8:46 am
john7 wrote:
Tue Mar 17, 2020 5:57 am
the code is working if I put it in main.py. The problem to import from another file.
  1. Create file wifi.py on your computer with the here bellow code
  2. Connect to your board rshell -p /dev/ttyUSB0
  3. Use rshell to copy wifi.py on your board cp wifi.py /pyboard/
  4. From rshell start repl
  5. You can now import your module from wifi import WIFI
  6. ...
I see. Thank you. So the file has to be located on the board. Too bad, it's hard to debug complicated applications. For now I'll stuff all my code in main.py.

Re: How to include a module

Posted: Tue Mar 17, 2020 3:14 pm
by stijn
Even though that works, I'd advice against it. Not just for the sake of doing 'the right thing' but mainly because it'll force you to learn Python and debugging techniques etc. It's lik the difference between trying random things until it works (not much learned), and investigating the problem followed by applying a fix of which you understand why it works.