How to detect typos in Python programs

Mel Wilson mwilson at the-wire.com
Fri Jul 25 12:49:53 EDT 2003


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

Testing really is a Good Thing.

        Regards.        Mel.




More information about the Python-list mailing list