"static" checking

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Moosebumps

    "static" checking

    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


  • Tim Ottinger

    #2
    Re: "static&qu ot; checking

    On Thu, 29 Jan 2004 04:37:17 +0000, Moosebumps wrote:
    [color=blue]
    > I'm wondering what kind of checking I can do on a python program before
    > running it (besides reading over every line).[/color]

    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

    Comment

    • Adrien Di Mascio

      #3
      Re: "static&qu ot; checking

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

      Hi,[color=blue]
      > 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.[/color]

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

      Cheers,

      --
      Adrien Di Mascio
      LOGILAB, Paris (France).
      http://www.logilab.com http://www.logilab.fr http://www.logilab.org


      Comment

      • Peter Hansen

        #4
        Re: "static&qu ot; checking

        Moosebumps wrote:[color=blue]
        >
        > 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.[/color]

        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

        Comment

        Working...