[docs] [issue34538] Remove encouragement to author a base class for all Exception subclasses in a module
report at bugs.python.org
Fri Aug 31 04:48:49 EDT 2018
INADA Naoki <songofacandy at gmail.com> added the comment:
For example, I found flask_mako's TemplateException in this search result.
Strictly speaking, this is not base exception class. It is wraps exception during template rendering. But "why this class is useful?" is very similar to base exception class.
It provides better traceback for mako template. They use this class for "particular reason", not because it's generally recommended practice.
And this "particular reason" shouldn't be in Python tutorial, clearly.
If we really need exception class hierarchy in tutorial, I think OSError is the best example. When opening a file, `except OSError:` is much better than `except (PermissionError, FileNotFound, ...)`. It's the most clear example when common base class for some distinct exceptions is useful.
Python tracker <report at bugs.python.org>
More information about the docs