LoginSignup
3
1

More than 5 years have passed since last update.

カスタム例外に関する微ネタ

Posted at

Fluent Python の 632 ページより

カスタムメイドな例外は通常、本体を持たないマーカークラスです。単に pass 文だけより、例外の用法を説明する docstring の方がよいです。

なるほど :innocent:

>>> class NoPokemonError(Exception):
...   """てもとには たたかえるポケモンが もういない!"""
...
>>> NoPokemonError.__doc__
'てもとには たたかえるポケモンが もういない!'
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1