python reload function and syntactically incorrect module
What happens when I reload a module in python and the new code for the module is syntactically incorrect? The reload(module) function d开发者_高级运维oesn'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
精彩评论