[Python-Dev] Add __exports__ to modules

Greg Stein gstein@lyra.org
Sun, 7 Jan 2001 04:27:57 -0800


It feels wrong. Whatever happened to the "we're all adults here" mantra.

Besides people asking for it, what is a good reason *for* it to be added?

Cheers,
-g

On Fri, Jan 05, 2001 at 03:14:41PM -0500, Guido van Rossum wrote:
> Please have a look at this SF patch:
> 
> http://sourceforge.net/patch/?func=detailpatch&patch_id=102808&group_id=5470
> 
> This implements control over which names defined in a module are
> externally visible: if there's a variable __exports__ in the module,
> it is a list of identifiers, and any access from outside the module to
> names not in the list is disallowed.  This affects access using the
> getattr and setattr protocols (which raise AttributeError for
> disallowed names), as well as "from M import v" (which raises
> ImportError).
> 
> I like it.  This has been asked for many times.  Does anybody see a
> reason why this should *not* be added?
> 
> Tim remarked that introducing this will prompt demands for a similar
> feature on classes and instances, where it will be hard to implement
> without causing a bit of a slowdown.  It causes a slight slowdown (an
> extra dictionary lookup for each use of "M.v") even when it is not
> used, but for accessing module variables that's acceptable.  I'm not
> so sure about instance variable references.
> 
> --Guido van Rossum (home page: http://www.python.org/~guido/)
> 
> _______________________________________________
> Python-Dev mailing list
> Python-Dev@python.org
> http://www.python.org/mailman/listinfo/python-dev

-- 
Greg Stein, http://www.lyra.org/