decorators.py 文件源码

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

项目:NLP.py 作者: PythonOptimizers 项目源码 文件源码
def deprecated(func):
    """Mark functions as deprecated.

    Using this decorator on a function or methos will emit a warning when the
    function is called.

    From http://wiki.python.org/moin/PythonDecoratorLibrary
    """
    @functools.wraps(func)
    def new_func(*args, **kwargs):
        warnings.warn_explicit(
            "Call to deprecated function/method {}.".format(func.__name__),
            category=DeprecationWarning,
            filename=func.func_code.co_filename,
            lineno=func.func_code.co_firstlineno + 1
        )
        return func(*args, **kwargs)
    return new_func
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号