CallTips.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:zippy 作者: securesystemslab 项目源码 文件源码
def get_argspec(ob):
    """Get a string describing the arguments for the given object."""
    argspec = ""
    if ob is not None:
        if isinstance(ob, type):
            fob = _find_constructor(ob)
            if fob is None:
                fob = lambda: None
        elif isinstance(ob, types.MethodType):
            fob = ob.__func__
        else:
            fob = ob
        if isinstance(fob, (types.FunctionType, types.LambdaType)):
            argspec = inspect.formatargspec(*inspect.getfullargspec(fob))
            pat = re.compile('self\,?\s*')
            argspec = pat.sub("", argspec)
        doc = getattr(ob, "__doc__", "")
        if doc:
            doc = doc.lstrip()
            pos = doc.find("\n")
            if pos < 0 or pos > 70:
                pos = 70
            if argspec:
                argspec += "\n"
            argspec += doc[:pos]
    return argspec

#################################################
#
# Test code
#
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号