[Tutor] should this cause a syntax error? [does pychecker work?]

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Sat Nov 2 17:18:02 2002


On 3 Nov 2002, Rob Brown-Bayliss wrote:

> On Sun, 2002-11-03 at 08:10, Magnus Lycka wrote:
>
> > Have you tried PyChecker? Maybe it would give a warning about such a
> > construct. (If it doesn't, that could be a suggested feature.) There
> > are certainly some unbound expressions that are normal, like lonely
> > function calls, and perhaps expressions with and/or, but I suppose a
> > lonely == will typically be an error.
>
> No I a havn't tried it.  I'm not really a fan of ides and things like
> that (but do like GUI builders).  I have changed my text editor to
> highlight the == so that they now stand out a bit more.


PyChecker is not an IDE, but a kind of source-code analysis that tries to
pick out common Python mistakes.  I'm personally curious to see what
PyChecker will say on that '==' code.  And bcause I've actually never used
PyChecker before, this will be fun for me.  *grin*

Let's see what happens...


###
dyoo@coffeetable:~$ cat test.py
print "this is a test"
1 == 1
print "did something trigger?"


dyoo@coffeetable:~$ pychecker test.py
Processing test...
this is a test
did something trigger?

Warnings...

test.py:2: Statement appears to have no effect
###


Wow!  That's very nice!  So yes, this PyChecker utility will point out
suspicious looking code.  We can grab PyChecker here:

    http://pychecker.sourceforge.net/