Skip Montanaro writes: > I thought I answered this question already when Fredrik asked it. In os.py, You did, and I'd have responded then had I been able to spare the time to reply. (I wasn't ignoring the topic.) > to build its __all__ list based upon the myriad different sets of symbols it > might have after it's fancy footwork importing from various os-dependent > modules, I think it's easiest to rely on those modules telling os what it > should export. But since C extensions inherantly control their exports very tightly, perhaps the right approach is to create the __all__ value in the code that needs it -- it usually won't be needed for C extensions, and the os module is a fairly special case anyway. Perhaps this helper would be a good approach: def _get_exports_list(module): try: return list(module.__all__) except AttributeError: return [n for n in dir(module) if n[0] != '_'] The os module could then use: _OS_EXPORTS = ['path', ...] if 'posix' in _names: ... __all__ = _get_exports_list(posix) del posix elif ...: ... _OS_EXPORTS = ['linesep', <all locally provded stuff>] __all__.extend(_OS_EXPORTS) -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Digital Creations
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4