Skip to content

Instantly share code, notes, and snippets.

@hxer
Created March 9, 2016 03:47
Show Gist options
  • Save hxer/c2b7840152fb14362f87 to your computer and use it in GitHub Desktop.
Save hxer/c2b7840152fb14362f87 to your computer and use it in GitHub Desktop.
查看python所有属性及文档描述
import inspect
def displayattrs(objects):
attrs = inspect.getmembers(objects)
for attr in attrs:
attr = attr[0]
filters = ['_', '__']
if not any(map(attr.startswith, filters)):
doc = getattr(objects, attr).__doc__
if doc:
doc = doc.rstrip()
print("{attr}:{doc}\n".format(attr=attr, doc=doc))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment