Created
March 9, 2016 03:47
-
-
Save hxer/c2b7840152fb14362f87 to your computer and use it in GitHub Desktop.
查看python所有属性及文档描述
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
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