找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 3704|回复: 0

[资源与教程] 3+版本调试通过的小段代码 - apihelper

4

主题

4

帖子

4

积分

贫民

积分
4
钟无艳 发表于 2017-3-24 13:46:22 | 显示全部楼层 |阅读模式
"""
This is a python program ,name:apihelper.py
python object info:
copy from dive into python
write my self.
just a test    ----ymirjoe@2016-3-28.
"""
def info (object,spacing=20, collapse = 1):
    """
    Show detail of Module,dictionary,class,list,tuple etc.
    Usage:
    1 , Import this python program:apihelper.py
    >>>import apihelper
    2 , info(object)
    >>>info(str)
    3 , other parameters like the function define:
    >>>info (object,spacing=20, collapse = 1)
    4 , You can use python help document like:
    >>>help(apihelper)"""

    methodList=[e for e in dir(object) if callable (getattr(object,e))]
    processFunc = collapse and (lambda s: " ".join(s.split())) or (lambda s: s)
    print("\n\n".join(["%s %s" %
                     (method.ljust(spacing),
                     processFunc(str(getattr(object,method).__doc__)))
                     for method in methodList]))
print(info.__doc__)
if __name__ == "__main__":
    pass
Python免费学习资源加扣扣1954532972验证备注py获取

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表