raising SyntaxError while parsing file?

Erik Max Francis max at alcyone.com
Fri Aug 31 21:55:48 EDT 2001


Roy Smith wrote:

> I've got a class which parses a data file, and I want to be able to
> signal
> a parse error.  Would it be appropriate to raise SyntaxError for that,
> or
> is SyntaxError really reserved for errors in the python code itself?

If it's parsing Python, I think that would be fine.  SyntaxErrors are
for errors in Python code, whether generated internally by the parser or
elsewhere.

If you want to raise custom exceptions regarding parse errors in
application-specified data, then you should use your own exception class
for that.  ParseError would be a fine name.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Even paranoids have real enemies.
\__/ Delmore Schwartz
    Physics reference / http://www.alcyone.com/max/reference/physics/
 A physics reference.



More information about the Python-list mailing list