小编Rac*_*son的帖子

在python中调用自定义错误类中的super是什么意思?

所以我在Python中有一个基于Python 2.7文档创建的简单自定义错误类:

class InvalidTeamError(Exception):
    def __init__(self, message='This user belongs to a different team'):
        self.message = message
Run Code Online (Sandbox Code Playgroud)

这让我W0231: __init__ method from base class %r is not called在PyLint中发出警告,所以我去查阅它并给出了"需要解释"的非常有用的描述.我通常只是忽略这个错误,但是我注意到在线代码包含了一个在自定义错误类的init方法开头调用super的问题,所以我的问题是:这样做是否真的有用,或者只是人试图安抚伪造的幽灵警告?

python exception pylint python-2.7

12
推荐指数
1
解决办法
1150
查看次数

标签 统计

exception ×1

pylint ×1

python ×1

python-2.7 ×1