inspection.py 文件源码

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

项目:qcore 作者: quora 项目源码 文件源码
def is_classmethod(fn):
    """Returns whether f is a classmethod."""
    # This is True for bound methods
    if not inspect.ismethod(fn):
        return False
    if not hasattr(fn, '__self__'):
        return False
    im_self = fn.__self__
    # This is None for instance methods on classes, but True
    # for instance methods on instances.
    if im_self is None:
        return False
    # This is True for class methods of new- and old-style classes, respectively
    return isinstance(im_self, six.class_types)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号