Created
August 27, 2017 20:33
-
-
Save marz619/a7c4d5566c7b7b3b731409edd7885ab7 to your computer and use it in GitHub Desktop.
Simple help & dir extensions for python
This file contains hidden or 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
def dird(cls): | |
""" | |
return a generator that yields all methods for `cls` | |
that do not start with underscore (_) | |
""" | |
cn = type(cls).__name__ | |
return ("{}.{}".format(cn, _) for _ in filter( | |
lambda _: not _.startswith("_"), | |
sorted(dir(cls)) | |
) | |
) | |
def helps(cls): | |
""" | |
calls help for all "public" methods on `cls` | |
""" | |
_ = list(map(help, dird(cls))) | |
# prints help info for `public` dict ({}) methods | |
helps({}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment