I had a frustrating time yesterday with a small Python program I wrote. I wasn't getting the results I expected, so I sprinkled print statements through it. I wasn't getting anywhere. I tossed it into Komodo to see if the background syntax checker would pick up something I was missing. I then stepped through it and finally noticed that I had messed up a variable name.

firstlist = [listItem[:12] for listItem in firstList]
     ^
when I meant

firstList = [listItem[:12] for listItem in firstList]
     ^
doh!

Later, I realized that I should have run it through Pychecker which would have picked it up immediately.

With that experience of learning the hard way, I'd recommend that you always run your code through Pychecker just after editing it and before running it.

In Perl, you can perl -c somehardtoreadperlprogram.pl that will just check the syntax. The above problem would have been caught in Perl since I always use strict. Is there a command line option in Python to do a Pychecker-like syntax check? I see a -t to check the tabs, but nothing to tell it to check the syntax but don't run it. If not, should Pychecker be part of the standard distribution? Am I missing something?

Mike

Go ahead and reply to me AND the list since I just get the digest.


_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Reply via email to