How to detect typos in Python programs

Manish Jethani manish.j at gmx.net
Fri Jul 25 22:10:19 CEST 2003


Mel Wilson wrote:

> In article <3F214977.AEB088C8 at engcorp.com>,
> Peter Hansen <peter at engcorp.com> wrote:
> 
>>Manish Jethani wrote:
>>
>>>Is there a way to detect typos in a Python program, before
>>>actually having to run it.  Let's say I have a function like this:
>>>
>>>  def server_closed_connection():
>>>    session.abost()
>>>
>>>Here, abort() is actually misspelt.  The only time my program
>>>follows this path is when the server disconnects from its
>>>end--and that's like once in 100 sessions.  [ ... ]
>>
>>You have no good alternative.  Why do you say it's impractical
>>to actually test your software before it's shipped?  Isn't it
>>more impractical to rely on your users to test the software,
>>thinking it should work?
> 
> 
> The proposed typo catcher would probably catch a typo like
> 
>         sys.edit (5)    # finger didn't get off home row
> 
> but it probably would *NOT* catch
> 
>         sys.exit (56)   # wide finger mashed two keys

1)  That's in a different class of typos.  Such things can't be
auto-detected in any language.  It will probably require close
examination by the human who wrote it in the first place, or
someone who has been debugging it.

2)  No on calls sys.exit() like that.  5, or 56, is probably a
constant defined somewhere (where such typos are easier to spot).

-Manish

-- 
Manish Jethani (manish.j at gmx.net)
phone (work) +91-80-51073488





More information about the Python-list mailing list