Spelling mistakes!

Terry Hancock hancock at anansispaceworks.com
Fri Jan 6 18:23:27 EST 2006


On 6 Jan 2006 07:30:41 -0800
"KraftDiner" <bobrien18 at yahoo.com> wrote:
> I've spent hours trying to find a bug that was a simple
> spelling mistake.

You're not the first. ;-)

> in an init method I declare a variable  self.someLongName
> 
> later in a different method of the class I use
> self.sumLongName
> Now I really meant self.someLongName.
> In fact I don't want a variable called sumLongName.
> Frankly how are you ever to know if this type of error is
> occuring?

Both "unit tests" and "interfaces" are useful for catching
simple errors like this one.  There is a 'unittest' module
in the Python standard library, and 'interface' modules are
available from the Zope 3 project and PyProtocols, both are
good.

Once you know you have a problem like this (or you've
decided to change a spelling), you can track down the
problem using grep, fix it with sed or use Python itself to
do the job if you really want to.

I once misspelled a name in a set of API methods, which was
very embarrassing (I spelled "fovea" as "fovia").  So then I
had to go through and change it, and report it in as an API
change so that a "patch" became a "minor version upgrade". 
Duh. Next time I use a dictionary before freezing an API!

Cheers,
Terry

-- 
Terry Hancock (hancock at AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com




More information about the Python-list mailing list