I am doing an exercise in Wesley Chun's book. Find files in the standard library modules that have doc strings. Then find the ones that don't, "the shame list". I came up with this to find the ones with;
#!/usr/bin/python
import os
import glob
import fileinput
import re

pypath = "/usr/lib/python2.6/"
fnames = glob.glob(os.path.join(pypath, '*.py'))

def read_doc():
    pattern = re.compile('"""*\w')
    for line in fileinput.input(fnames):
        if pattern.match(line):
            print 'Doc String Found: ', fileinput.filename(), line

read_doc()

There must have been an easier way :)

Now I have a problem, I can not figure out how to compare the fnames with the result fileinput.filename() and get a list of any that don,t have doc strings.

thanks
--
Powered by Gentoo GNU/Linux
http://linuxcrazy.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to