The “correct” way to define an exception in Python without PyLint complaining

前端 未结 3 1195
长发绾君心
长发绾君心 2021-02-12 01:43

I\'m trying to define my own (very simple) exception class in Python 2.6, but no matter how I do it I get some warning.

First, the simplest way:

class My         


        
3条回答
  •  忘了有多久
    2021-02-12 01:56

    Alright, I think I figured it out. This seems to keep PyLint happy:

    class MyException(Exception):
        def __init__(self, message):
            Exception.__init__(self, message)
            self.message = message
    

提交回复
热议问题