compilation
Thomas Wouters
thomas at xs4all.nl
Mon Jun 26 14:45:13 EDT 2000
On 26 Jun 2000 17:37:19 GMT, Michael P. Soulier
<msoulier at nortelnetworks.com> 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?
No. (other than 'python -c "import <myscript>"')
It's not that big a deal, though, because the only thing done is syntax
checking -- and not code validity, as perl -cw does. 99% of Pythons' errors
are runtime errors, especially since true syntax errors are generated right
away, preventing a legion of other errors from popping up at the same time
;-)
Python also doesn't give warnings, unless you use python -t, in which case
it'll give a warning about inconsistent indentation (mixing tabs & spaces).
In short, a 'python -cw' wouldn't be too useful anyway. You're probably
better off with some decent unit testing ;-)
(Then again, contrary to my C and Perl code, both a fair bit, my Python code
almost never has syntax/programming errors, and most of my programs are
simple enough to do the unit testing 'by hand' ;)
perl-ly y'rs,
Thomas.
More information about the Python-list
mailing list