pydoc and imported modules

Ron Adam rrr at ronadam.com
Wed Apr 25 23:55:13 CEST 2007


schpok at gmail.com wrote:
> When I "from foo import *" in my __init__.py, sometimes module foo's
> docs will be expanded in the pydocs. It seems to depend in what
> language foo was implemented.
> 
> For example, if you "from math import *" in your __init__.py, you will
> see math's members will appear in the resulting pydocs, as though it's
> part of your module. The behavior is consistent across the C modules I
> am writing.
> 
> However, if you "from foo import *" in your __init__.py, and foo is a
> python file (not a module written in C), foo's members don't appear in
> the resulting pydocs. This also seems to occur in some boost::python
> bindings.
> 
> What is expected behavior? How do ensure foo's docs do or don't appear
> in help, regardless of their implementation language?
> 
> Thanks,
> Schpok

Pydoc doesn't check the __module__ attribute of the items imported, it just 
displays what is in the modules name space as if it was defined in that module.

In __init__.py files where an __all__ variable is defined, it won't show 
items that aren't in __all__.  This is probably what you are seeing.

I'm currently rewriting pydoc, so what behavior would you like to see?

Cheers,
    Ron




More information about the Python-list mailing list