Something like Perl's -c flag?

Oleg Broytmann phd at phd.pp.ru
Sat Sep 1 02:44:07 EDT 2001


On 31 Aug 2001, Mark Atwood wrote:
MA> Does the Python interpreter have anything like Perl's -c flag, which
MA> does a static syntax and sanity check without actually running the
MA> script?

   Just compile the script. Like this:

import sys
from py_compile import compile

if len(sys.argv) <= 1:
   sys.exit(1)

for file in sys.argv[1:]:
   compile(file)

Oleg.
----
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list