Legitimate to raise SyntaxError for non-Python syntax errors?
tim.one at home.com
Sat Jun 23 11:40:13 CEST 2001
> Is it legitimate to use the SyntaxError exception for non-Python
> syntax errors, say by a parser when it encounters violations in the
> syntax of the data format or mini-language it is parsing? I'd always
> assumed that SyntaxError was meant for just Python syntax errors, ...
I doubt anyone will object. Thousands of programs reuse Python's ValueError and
TypeError, and while SyntaxError reuse is less common, it seems like it's much
the same thing. Just because Guido took all the good exception names first
doesn't mean he gets to keep them to himself <wink>.
I'd draw the line at trying to reuse SystemError: that's used by Python in the
role of an assert, raised when "something impossible" happens in the core. So
when that happens, no way do you want *your* code to be a suspect.
don't-do-the-crime-if-you-can't-do-the-time-ly y'rs - tim
More information about the Python-list