how to do *simple* syntax checking?

Fredrik Lundh fredrik at pythonware.com
Wed Dec 1 04:17:07 EST 1999


Preston Landers <prestonlanders at my-deja.com> wrote:
>  I thought that Python's compile() function would be what I want,
> because I thought that the SyntaxError exception was thrown when making
> bytecode.  But that's not the case, unless I was notably un-thorough in
> my investigation.

>>> compile("""
... it's supposed to work
... maybe:
... you should try again?
... """, "", "exec")
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "<string>", line 2
    it's supposed to work
                        ^
SyntaxError: invalid token

</F>





More information about the Python-list mailing list