Chris Angelico <ros...@gmail.com> wrote: > Yes and no. Syntax errors are detected when the script is compiled, so > you can't do something like this:
You're right, except that Python is never compiled, it was just checked for syntax error before interpreting code. > > However, you can catch this at some form of outer level. If you're > using exec/eval to run the code, you can guard that: Your solution are OK, but that's not very "pythonic". Python was not design to be used in such a way (intercepting syntax error). There was hack to made somthing like requested but that only a hack and should not be used in real world. -- Pierre-Alain Dorange Moof <http://clarus.chez-alice.fr/> Ce message est sous licence Creative Commons "by-nc-sa-2.0" <http://creativecommons.org/licenses/by-nc-sa/2.0/fr/> -- https://mail.python.org/mailman/listinfo/python-list