compilation
Oleg Broytmann
phd at phd.russ.ru
Tue Jun 27 03:52:36 EDT 2000
On 26 Jun 2000, Michael P. Soulier wrote:
> Hey people. I tried the FAQ, and I can't find this. I'm a Perl
> programmer exploring Python, and I'm wondering how to do a simple compile pass
> on python source to check syntax. In Perl, I'd just do a perl -cw sourcefile
> and it would do a quick compile pass with warnings on. I know I can start the
> interpreter and import the file as a module, but that's not always desirable.
> Is there a simple command-line way to do this?
#! /bin/sh
if [ -z "$1" ]; then
echo "Usage: compyle file.py..."
exit 1
fi
TEMPLATE="from py_compile import compile; compile('"
for file in $*; do
pgm=$TEMPLATE$file"')"
python -c "$pgm" || exit 1
python -OOc "$pgm" || exit 1
done
(I know I call python in the loop instead of looping inside python; I do
this by purpose).
Oleg. (All opinions are mine and not of my employer)
----
Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-list
mailing list