how to abort on syntax errors

kyosohma at kyosohma at
Mon Mar 26 19:37:21 CEST 2007

On Mar 26, 12:21 pm, "Josh" <n... at> wrote:
> I have a lot of except Exception, e statements in my code, which poses some
> problems. One of the biggest is whenever I refactor even the triviallest
> thing in my code.
> I would like python to abort, almost as if it were a compile-time error,
> whenever it cannot find a function, or if I introduced a syntax error. But,
> instead, it merrily proceeds on its way.
> Is there some idiom that you use in situations like these?
> thanks,
> josh

Try sticking in an

  #do something
except SyntaxError, e:
   print e
except Exception, e:
   print e

# You put in as many exceptions as you like.


More information about the Python-list mailing list