[Python-Dev] Add __exports__ to modules

Paul Prescod paulp@ActiveState.com
Wed, 10 Jan 2001 12:08:31 -0800


Guido van Rossum wrote:
> 
> ...
> 
> Yes -- I came up with the same thought.
> 
> So here's a plan: somebody please submit a patch that does only one
> thing: from...import * looks for __all__ and if it exists, imports
> exactly those names.  No changes to dir(), or anything.

Why? From my point of view, the changes to dir() are much more
important. I seldom tell newbies about import * but I always tell them
how they can browse objects (especially modules) with dir. If dir() is
changed then IDEs and so forth would use that and inherit the right
behavior. If the module exporting behavior gets more sophisticated in a
future version of Python they will continue to inherit the behavior.

Also, dir() could look for an __all__ on all objects including "module
proxies", classes and "plain old instances". In other words we can
extend the convention to other objects "for free".

 Paul