Created
May 31, 2018 10:42
-
-
Save huntie/37e060d52a2787c3d8da033e37ae9371 to your computer and use it in GitHub Desktop.
A small reflection utility to access public module members as a dict
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def unpack_module(module) -> dict: | |
""" | |
Return the members of an imported package or module explicitly exported | |
using __all__. | |
""" | |
return {k: module.__dict__[k] for k in module.__dict__.get('__all__', [])} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment