Skip to content

Instantly share code, notes, and snippets.

@marz619
Created August 27, 2017 20:33
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 marz619/a7c4d5566c7b7b3b731409edd7885ab7 to your computer and use it in GitHub Desktop.
Save marz619/a7c4d5566c7b7b3b731409edd7885ab7 to your computer and use it in GitHub Desktop.
Simple help & dir extensions for python
#!/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