[Python-Dev] dir() and __all__

Raymond Hettinger python at rcn.com
Sat Feb 16 04:18:59 CET 2008


[Raymond]
>> Should dir(module) use __all__ when defined?

[GvR]
> It's not consistent with what dir() of a class or instance does though.
> 
> -1.

Perhaps there is another solution. Have dir() exclude objects
which are modules.  For example, dir(logging) would exclude
sys, os, types, time, string, cStringIO, and traceback.


Raymond


More information about the Python-Dev mailing list