Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] Add __exports__ to modules

Guido van Rossumguido@python.org
Fri, 05 Jan 2001 15:14:41 -0500


Please have a look at this SF patch:http://sourceforge.net/patch/?func=detailpatch&patch_id=102808&group_id=5470This implements control over which names defined in a module areexternally visible: if there's a variable __exports__ in the module,it is a list of identifiers, and any access from outside the module tonames not in the list is disallowed.  This affects access using thegetattr and setattr protocols (which raise AttributeError fordisallowed names), as well as "from M import v" (which raisesImportError).I like it.  This has been asked for many times.  Does anybody see areason why this should *not* be added?Tim remarked that introducing this will prompt demands for a similarfeature on classes and instances, where it will be hard to implementwithout causing a bit of a slowdown.  It causes a slight slowdown (anextra dictionary lookup for each use of "M.v") even when it is notused, but for accessing module variables that's acceptable.  I'm notso sure about instance variable references.--Guido van Rossum (home page:http://www.python.org/~guido/)


[8]ページ先頭

©2009-2025 Movatter.jp