How to use the pass statement?

前端 未结 15 2394
旧时难觅i
旧时难觅i 2020-11-22 15:03

I am in the process of learning Python and I have reached the section about the pass statement. The guide I\'m using defines it as being a Null sta

15条回答
  •  悲哀的现实
    2020-11-22 15:35

    A common use case where it can be used 'as is' is to override a class just to create a type (which is otherwise the same as the superclass), e.g.

    class Error(Exception):
        pass
    

    So you can raise and catch Error exceptions. What matters here is the type of exception, rather than the content.

提交回复
热议问题