How to warn about class (name) deprecation

后端 未结 7 1471
滥情空心
滥情空心 2020-12-13 12:21

I have renamed a python class that is part of a library. I am willing to leave a possibility to use its previous name for some time but would like to warn user that it\'s de

7条回答
  •  温柔的废话
    2020-12-13 13:04

    Please have a look at warnings.warn.

    As you'll see, the example in the documentation is a deprecation warning:

    def deprecation(message):
        warnings.warn(message, DeprecationWarning, stacklevel=2)
    

提交回复
热议问题