<div dir="ltr"><div>Dear Ian Cordasco,</div><div><br> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">So as a maintainer/contributor to three of those I agree. But they're<br>
external dependencies which I sense is something you don't want.<br>
<br>
The reality is that you can compile this code with some standard<br>
library modules and they'll give you the feedback you want. If you<br>
were to run this code you'd get a NameErrors for the first line where<br>
you expect a warning and you would get a SyntaxError for the second<br>
else statement after the first. pyflakes and flake8 turn those into<br>
error codes for you. So really, python already comes with the warnings<br>
on because doing<br>
<br>
$ python test.py<br>
<br>
Would first result in a SyntaxError (because of your else following<br>
the first else) and then once that's been fixed, you'd get a<br>
NameError.<br>
<br>
Disclaimer: I didn't actually run the code so I may have the order of<br>
errors wrong, but I think this is roughly correct.</blockquote><div><br></div><div>I am sorry..I mean:<br><br>#!/usr/bin/python<br><br>word = raw_input("Enter line : ")<br><br>if word == "hello":<br> print ("You enter \'hello\'")<br>else:<br> if world == "buy": #Error! should be word not world<br> print "Buy"<br> else:<br> dasdas<br><br></div><div>We will not have a problem with else.<br><br></div><div>Okay, we can split this example:<br><br></div><div>The first part is:<br></div><div><br>#!/usr/bin/python<br><br><b>word</b> = raw_input("Enter line : ")<br><br>if <b>word</b> == "hello":<br> print ("You enter \'hello\'")<br>else:<br> if <b>world</b> == "buy": <b>#Error! should be word not world</b><br> print "Buy"<br></div><div><br><b>"NameError: name 'world' is not defined" - only in case if the word != 'hello'</b>!!<br><br></div><div>The second one:<br><br>#!/usr/bin/python<br><br><b>word</b> = raw_input("Enter line : ")<br><br>if <b>word</b> == "hello":<br> print ("You enter \'hello\'")<br>else:<br> if <b>word</b> == "buy": #Now correct!<br> print "Buy"<br></div><div> else<br></div><div> iamnotfunction <b>#Error</b><br><br><b>"NameError: name 'iamnotfunction' is not defined" only in case if word != 'hello' and word != "buy"</b>!!<br><br></div><div>So I can type whatever I want in else block and someone can detect it after the several years..<br></div><div><br></div><div>And the first thing that I have to do programming in Python is to download analyser tool..I understand <span id="result_box" class="" lang="en"><span class="">the importance of static analyser tools, but in this case (to check simple things like a variables and functions names) it is like </span></span><span lang="en"><span>"To use a sledge-hammer to crack a nut.".<br></span></span></div><div><br><br></div><div>Many thanks!<br><br></div><div>- Eduard<br><br></div><div>PS. Within C++ or other languages I should use static analyser tools to check real bug-prone situation, but in new, modern Python I should use third-party tools to check the real simple errata. <br><br>Maybe I do not understand something..<br></div></div>