Spell-checking Python source code

Ricardo Aráoz ricaraoz at gmail.com
Sat Sep 8 17:32:45 EDT 2007


John Zenger wrote:
> To my horror, someone pointed out to me yesterday that a web app I
> wrote has been prominently displaying a misspelled word.  The word was
> buried in my code.
> 
> Is there a utility out there that will help spell-check literal
> strings entered into Python source code?  I don't mean spell-check
> strings entered by the user; I mean, go through the .py file, isolate
> strings, and tell me when the strings contain misspelled words.  In an
> ideal world, my IDE would do this with a red wavy line.
> 
> I guess a second-best thing would be an easy technique to open a .py
> file and isolate all strings in it.
> 
> (I know that the better practice is to isolate user-displayed strings
> from the code, but in this case that just didn't happen.)
> 

Use the re module, identify the strings and write them to another file,
then open the file with your spell checker. Program shouldn't be more
than 10 lines.






More information about the Python-list mailing list