[Tutor] Spell checking source code?

David david at abbottdavid.com
Tue Jun 2 22:07:17 CEST 2009


ALAN GAULD wrote:

> But that will check the whole file. The OP only wanted to spell
> check the comments. Unless I'm missing something?

> "Allen Fowler" <allen.fowler at yahoo.com> wrote 
>     Are there any utilities to help "spell check" source code?  (Docstrings, etc)
> 
I came up with this;
[sample file]
#!/usr/bin/python

def doc_test():
     """Do notheing, but document it.

     No, really, it doesn't do anything.
     """
     pass
[test program]
#!/usr/bin/python
from doc_function_test import doc_test
from enchant.checker import SpellChecker

doc_string = doc_test.__doc__
doc_string = str(doc_string)
chkr = SpellChecker("en_US")
chkr.set_text(doc_string)
for err in chkr:
     print "Error:", err.word

[results]
python spell_check_doc.py
Error: notheing




-- 
Powered by Gentoo GNU/Linux
http://linuxcrazy.com


More information about the Tutor mailing list