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 reboot (module) function does not seem to raise any exceptions. Is there a way to determine if a reboot was successful or failed?

+3
source share
1 answer

The reload () command should raise a SyntaxError:

In [34]: import test
# This works fine

After creating a syntax error in test.py: (modified import -> pimport)

In [35]: reload(test)
------------------------------------------------------------
   File "/home/unutbu/pybin/test.py", line 2
     pimport itertools
                     ^
SyntaxError: invalid syntax
+3
source

Source: https://habr.com/ru/post/1723553/


All Articles