ISO all functions+methods+classes without docstring

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Wed Dec 23 16:39:27 EST 2009


On Wed, 23 Dec 2009 21:08:02 +0000, kj wrote:

> I'm looking for a good way to get a listing of all the undocumented
> (i.e. docstring-less) functions, classes, and methods as defined in a
> (largish) library of files.
> 
> What's a good way to get this information?


list_of_modules = []
for module_name in list_of_files:
    list_of_modules.append( __import__(module_name) )

for module in list_of_modules:
    for name in dir(module):
        obj = getattr(module, name)
        doc = getattr(obj, '__doc__', None)
        if doc is None:
            print module, name


The only complication is that dir deliberately only shows "interesting" 
attributes, however that is defined. If this doesn't do what what you 
want, you may prefer to write your own function. The inspect module will 
probably come in handy.



-- 
Steven



More information about the Python-list mailing list