utils.py 文件源码

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

项目:abusehelper 作者: Exploit-install 项目源码 文件源码
def format_type(value):
    """
    Return a full name of the value's type.

    >>> import abusehelper.core.events
    >>> format_type(abusehelper.core.events.Event())
    'abusehelper.core.events.Event'

    The package path prefix for builtin types gets omitted.

    >>> format_type(abusehelper.core.events)
    'module'
    >>> format_type(abusehelper.core.events.Event)
    'type'
    >>> format_type(1)
    'int'
    """

    type_ = type(value)
    name = type_.__name__
    module = inspect.getmodule(type_)
    if module is not None and module.__name__ != "__builtin__":
        name = module.__name__ + "." + name
    return name
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号