How to perform syntax check in Python
Fredrik Lundh
fredrik at pythonware.com
Thu Nov 11 03:17:15 EST 1999
Meera <meera_bavadekar at hp.com> wrote:
> I am looking for a utility to perform syntax validation in python.
> Consider following code -
>
> try:
> a = 3
> print a
> #Do some more processing
> except:
> print b
>
> The fact that variable b is not defined is known only when we get
> exception.
> We will get 'NameError exception' _not_ the actual exception we are
> expecting.
>
> When we have multi-developer and multi-platform environment - such
> feature is crucial. This is one area which I would like python to improve
> over conventional language.
having been there and done that, I'd say a good testing
harness is a better way to address that -- helps you find
both code glitches and real bugs (!).
but if you really prefer linting, check out chordate's pylint
utility, available from:
http://www.chordate.com/kwParsing/index.html
</F>
<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
(news: just posted an errata for the 'first printing') -->
More information about the Python-list
mailing list