[issue29446] Improve tkinter 'import *' situation

Eric V. Smith report at bugs.python.org
Sun Feb 5 10:35:45 EST 2017


Eric V. Smith added the comment:

Instead of:
__all__ = [name for name in globals() if not name.startswith('_') and name not in {'enum', 're', 'sys', 'wantobjects'}]

Maybe this would be less fragile:
import types
__all__ = [name for name, obj in globals().items() if not name.startswith('_') and not isinstance(obj, types.ModuleType) and name not in {'wantobjects'}]

That is, exclude all modules. Admittedly, I had to import types, but there are other ways to do this test without that import.

----------
nosy: +eric.smith

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


More information about the Python-bugs-list mailing list