-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to imported files not reflected in running code #44
Comments
{Disclaimer: I am a barely competent beginner with Python/MicroPython. Not speaking on behalf of the ViperIDE team.} Might that be the actual 'expected' behaviour? (And that your expectation is incorrect?) With full-fat Python I think import is a 'lazy' operation that will not be repeated if the corresponding namespace already exists? Perhaps micropython is using the same behaviour? |
You should just be able to do a soft reset on the device instead of dis/re-connecting. As far as I understand it, this is by design. |
Yes, this is how MicroPython itself works. |
Shouldn't this be handled by the IDE? Possibly soft-reset on each run (ala Thonny) or soft-reset on every file save. Because this behavior even if "expected" is pretty stupid and wastes time for people who don't expect it. What is the underlying cause of this? Since the file is imported twice in the same interpreter session, its not reloaded? |
Well you can see the same behavior in just the REPL... Put a You will see that it only prints You have to reload the device to get it to 'un-import'. Perhaps there could be an option in the IDE to "Auto reload on run" though? @vshymanskyy what do you think? It should probably be a toggleable setting so that the people who don't want this behaviour don't get upset. |
Adding an option to auto-soft-reset is easy |
Changes to imported files are not reflected in running code
Setup
To Reproduce
Steps to reproduce the behavior:
Create file "importtest.py" with the following code:
def somefunc():
print("123")
Create file "importtestrun.py" with the following code:
import importtest
importtest.somefunc()
Run "importtestrun.py", and see that the behavior is as expected
Change "importtest.py"
Run "importtestrun.py", and see that the behavior is incorrect. (its still running old code)
Expected behavior
Changes in importtest.py should be reflected when importtestrun.py is run. Unfortunately this is not the case and the device needs to be disconnected and reconnected to resolve the issue and the import to work as expected with the new changes
The text was updated successfully, but these errors were encountered: