importing fully qualified scripts to check syntax

Gabriel Genellina gagsl-py2 at
Sat Aug 8 03:16:06 CEST 2009

En Fri, 07 Aug 2009 17:29:28 -0300, horos11 <horos11 at> escribió:

> I'm trying to make a syntax checker, where I say:
> python -c "import /path/to/script"
> to check the syntax of the script named '/path/to/script' (note: no py
> extension needed). Of course this doesn't work because the
> functionality for import is bundled up with the environment..

Try the py_compile module in the standard library:

The import statement does more than just checking syntax. You may want to  
start the interpreter with the -tt option also.

Gabriel Genellina

More information about the Python-list mailing list