Spell-checking Python source code

David wizzardx at gmail.com
Sat Sep 8 23:44:10 CEST 2007

> >
> > (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.

Have a look at the tokenize python module for the regular expressions
for extracting strings (for all possible Python string formats). On a
Debian box you can find it here: /usr/lib/python2.4/tokenize.py

It would probably be simpler to hack a copy of that script so it
writes all the strings in your source to a text file, which you then

Another method would be to log all the strings your web app writes, to
a text file, then run through your entire site, and then spellcheck
your logfile.

More information about the Python-list mailing list