Search found 8 matches

by sebi
Sat Apr 06, 2019 6:36 pm
Forum: Programs, Libraries and Tools
Topic: [Solved] Noob has questions about exec() and import()
Replies: 11
Views: 366

Re: Noob has questions about exec() and import()

Here are some of the findings I made while investigating the issues relative to this post: - from mod import * is different from entering the content of mod.py directly into the REPL due to name binding. - exec("string") is not implemented the same way in MPY as in CPY. In MPY it always runs the str...
by sebi
Mon Apr 01, 2019 8:19 am
Forum: Programs, Libraries and Tools
Topic: [Solved] Noob has questions about exec() and import()
Replies: 11
Views: 366

Re: Noob has questions about exec() and import()

At this time, I don't have a specific goal in mind other than understanding the border cases I encountered in the past that still puzzle me (latest piece of code I adapted in MPY is a serial driver for the Dongbu HerkuleX DRS-0602 servo). import myscript_file works indeed, but I disagree it's not li...
by sebi
Sun Mar 31, 2019 8:45 pm
Forum: Programs, Libraries and Tools
Topic: [Solved] Noob has questions about exec() and import()
Replies: 11
Views: 366

Re: Noob has questions about exec() and import()

Indeed the only good way is code = reload(code) . Is there a similar way to reload a module after a from code import * ? Actually, currently I prefer to use exec(open("code.py").read()) instead as I don't understand the program behavior after a from code import * . Indeed, for code.py being: a = 0 d...
by sebi
Thu Mar 28, 2019 3:36 am
Forum: Programs, Libraries and Tools
Topic: [Solved] Noob has questions about exec() and import()
Replies: 11
Views: 366

Re: Noob has questions about exec() and import()

Dear Dave, Thanks a lot for your explanations! It really gave me a lot to think of, especially that notion of local variable holding the code. I searched for a way to get reload(mod) modify that variable directly, and eventually I modified its last line such a way: def reload(mod): import sys mod_na...
by sebi
Wed Mar 27, 2019 10:39 pm
Forum: Programs, Libraries and Tools
Topic: [Solved] Noob has questions about exec() and import()
Replies: 11
Views: 366

Re: Noob has questions about exec() and import()

Dear OutoftheBOTS_, Thanks for your assistance. I followed your instructions: - modified boot.py with your code - rebooted the MicroPython device - loaded the content of code.py into RAM using import - printed the value of code.a.b - modified the value of a.b in code.py - exectued reload(code) - pri...
by sebi
Wed Mar 27, 2019 2:07 am
Forum: Programs, Libraries and Tools
Topic: [Solved] Noob has questions about exec() and import()
Replies: 11
Views: 366

Re: Noob has questions about exec() and import()

Thanks for your reply OutoftheBOTS_ MicroPython v1.10-131-g952139904 on 2019-02-26; PYBv1.1 with STM32F405RG Type "help()" for more information. >>> from make import do2 >>> __class__ __name__ do2 >>> do2.__ __class__ __name__ >>> do2.a.b Traceback (most recent call last): File "<stdin>", line 1, in...
by sebi
Tue Mar 26, 2019 11:32 pm
Forum: Programs, Libraries and Tools
Topic: [Solved] Noob has questions about exec() and import()
Replies: 11
Views: 366

[Solved] Noob has questions about exec() and import()

Dear all, My problem has to do with exec , import and globals For ease of illustration, I create a file named code.py , the content of which being: class A: pass a=A() a.b=1 def toggle(): a.b*=-1 toggle() When I type the following commands under MicroPython's prompt I get: MicroPython v1.10-131-g952...
by sebi
Fri Feb 08, 2019 5:41 pm
Forum: ESP8266 boards
Topic: ESP01 MicroPython install
Replies: 44
Views: 17319

Re: ESP01 MicroPython install

I had the same kind of issues with an ESP-01 (with 1MB Flash).
Then I found this post: https://www.esp8266.com/viewtopic.php?p=73529
Flashing my ESP-01 with with DOUT (Dual Output) instead of DIO or QIO solved it.