What happens when I reload a module in python and the new code for the module is syntactically incorrect? The reload(module) function doesn't seem to be throwing any exception. Is there any way to determine if the reload was successful or failed?
The reload() command should raise a SyntaxError:
In [34]: import test
# This works fine
After making a syntax error in test.py: (changed import --> pimport)
In [35]: reload(test)
------------------------------------------------------------
File "/home/unutbu/pybin/test.py", line 2
pimport itertools
^
SyntaxError: invalid syntax
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With