[Python-ideas] Add 'use warnings' directive, like in Perl

Chris Barker chris.barker at noaa.gov
Tue Feb 10 22:12:25 CET 2015


On Tue, Feb 10, 2015 at 11:53 AM, Eduard Bondarenko <eduardbpy at gmail.com>
wrote:

> Well, Perl also dynamic language, but except the usage of the additional
> analyser tools he provides 'use warning' directive and many Perl's
> developers use this feature.
>
> Why you do not want to add such feature in Python ?
>

I don't think anyone is saying that pre-run-time static analysis isn't
useful.

And I'd bet that most of the folks on this list use some or all of the
tools mentioned.

So the question is -- should some small subset of such analysis be built-in
to the interpreter? -- and I. for one, don't think it should, at least at
this point.

Seems very strange that Python checks ordinary blocks like 'if', 'else',
> 'def' statement and others..We could just have a big amount of tools to
> check this.
>

Python checks syntax before it compiles (or while it compiles), because,
well, it literally can't compile the code without correct syntax.  It
doesn't check things like names existing because those names could  be
created at run time.

If a line of code never runs during testing, then it can only be assumed to
be incorrect.

If it does run during tests, then the really quick and easy stuff like
mis-typed names will be caught right away. As there is no long compile-link
step, there isn't much to be gained by the interpreter catching these
things (that may not actually be errors) in the compile step.

-Chris


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150210/a9f4d95a/attachment.html>


More information about the Python-ideas mailing list