[issue26632] @public - an __all__ decorator

Nick Coghlan report at bugs.python.org
Tue Jan 10 01:20:18 EST 2017


Nick Coghlan added the comment:

Chiming in so Barry & Zach can take this feedback into account for any future proposal:

- I think the specific term "public" has too much baggage from other languages, especially in the sense that it implies that "private" is the default. In reality, all attributes in Python are public, with __all__ serving as executable documentation and a constraint on wildcard exports

- the notion of an automatically supplied __all__ object that defaults to reporting [name for name in dir(module) if not name.startswith("_")] has a lot more to recommend it (as it encodes the default wildcard export behaviour directly into the language implementation, rather than requiring that module analysis tools implement that default themselves)

- given "__all__" as the base name, the method name for class and function registration could just be the generic "__all__.register" (although "__all__.export" would also work, since it's the counterpart of "import *")

- using an object namespace would allow for other registration methods if that seemed appropriate

Even then, I'm at best +0 on the proposal, but I also don't make heavy use of code development helpers (IDEs, etc)

----------
nosy: +ncoghlan

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26632>
_______________________________________


More information about the Python-bugs-list mailing list