开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜