[issue35446] incorrect example
Alistsair Lenhard
report at bugs.python.org
Sun Dec 9 07:40:06 EST 2018
New submission from Alistsair Lenhard <alistair.lenhard at googlemail.com>:
under: https://docs.python.org/3/tutorial/errors.html
Original it says:
"Note that if the except clauses were reversed (with except B first), it would have printed B, B, B — the first matching except clause is triggered."
It should read:
"Note that if the except clauses were reversed (with except B first), it would have printed D, D, D — the first matching except clause is triggered."
As D is the first expression in the print statement.
So if the expression is changed to "except B:"
class B(Exception):
pass
class C(B):
pass
class D(C):
pass
for cls in [B, C, D]:
try:
raise cls()
except B:
print("D")
except C:
print("C")
except B:
print("B")
Result is:
D
D
D
----------
assignee: docs at python
components: Documentation
messages: 331428
nosy: Alistair, docs at python
priority: normal
severity: normal
status: open
title: incorrect example
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35446>
_______________________________________
More information about the Python-bugs-list
mailing list