Skip to content

Instantly share code, notes, and snippets.

@huntie
Created May 31, 2018 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huntie/37e060d52a2787c3d8da033e37ae9371 to your computer and use it in GitHub Desktop.
Save huntie/37e060d52a2787c3d8da033e37ae9371 to your computer and use it in GitHub Desktop.
A small reflection utility to access public module members as a dict
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