"static" checking

M

Moosebumps

I'm wondering what kind of checking I can do on a python program before
running it (besides reading over every line). I hate running a long python
script, only to have it fail at the end because I misspelled a function
name, or made some other silly mistake that a compiler would normally catch.
Then I have to run it all over again to see what happened or come up with
some sort of short test.

I usually do try to isolate the new parts of my code, and run them first
with some dummy data that will run fast. But that is not always possible
because of dependencies, and it would be nice to have some sort of sanity
check up front.

I noticed there is a "check" function in IDLE, and I've tried running it but
it never does anything. Maybe it is not catching the kinds of errors that
are biting me.

thanks,
MB
 
T

Tim Ottinger

I'm wondering what kind of checking I can do on a python program before
running it (besides reading over every line).

Check in IDLE isn't bad. I'm not sure what it's running. I know that it
runs tabnanny and probably runs pychecker also. Pychecker is quite handy.

Tim Ottinger
 
A

Adrien Di Mascio

Le Thu, 29 Jan 2004 04:37:17 +0000, Moosebumps a écrit :

Hi,
I'm wondering what kind of checking I can do on a python program before
running it (besides reading over every line). I hate running a long python
script, only to have it fail at the end because I misspelled a function
name, or made some other silly mistake that a compiler would normally catch.
Then I have to run it all over again to see what happened or come up with
some sort of short test.

Have a look at pylint (http://www.logilab.org/projects/pylint)

Cheers,
 
P

Peter Hansen

Moosebumps said:
I'm wondering what kind of checking I can do on a python program before
running it (besides reading over every line). I hate running a long python
script, only to have it fail at the end because I misspelled a function
name, or made some other silly mistake that a compiler would normally catch.
Then I have to run it all over again to see what happened or come up with
some sort of short test.

I usually do try to isolate the new parts of my code, and run them first
with some dummy data that will run fast. But that is not always possible
because of dependencies, and it would be nice to have some sort of sanity
check up front.

These issues largely go away once you start doing test-driven development.
See, for example, Mark Pilgrim's excellent introduction in his book at
http://www.diveintopython.org/ (see the link under "unit testing"), or
Kent Beck's paper book "Test-Driven Development" (published by Addison Wesley).

With this approach, your code generally won't have those dependencies
(sometimes the approach has to be tried before someone can really believe
that, but it's true) and you find your spelling mistakes, and many other
problems that static checking can't find, in seconds without no more
effort than it takes to run a batch file.

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top