开发者

python reload function and syntactically incorrect module

开发者 https://www.devze.com 2022-12-12 17:38 出处:网络
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 seemto be throwing any exception. Is there

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

精彩评论

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