PEP 8: Discourage use of return/break/continue in finally (#1174)
This commit is contained in:
parent
8400ea55ac
commit
2ce88849fd
14
pep-0008.txt
14
pep-0008.txt
|
@ -1335,6 +1335,20 @@ Programming Recommendations
|
||||||
No: if greeting == True:
|
No: if greeting == True:
|
||||||
Worse: if greeting is True:
|
Worse: if greeting is True:
|
||||||
|
|
||||||
|
- Use of the flow control statements ``return``/``break``/``continue``
|
||||||
|
within the finally suite of a ``try...finally``, where the flow control
|
||||||
|
statement would jump outside the finally suite, is discouraged. This
|
||||||
|
is because such statements will implicitly cancel any active exception
|
||||||
|
that is propagating through the finally suite.
|
||||||
|
|
||||||
|
No::
|
||||||
|
|
||||||
|
def foo():
|
||||||
|
try:
|
||||||
|
1 / 0
|
||||||
|
finally:
|
||||||
|
return 42
|
||||||
|
|
||||||
Function Annotations
|
Function Annotations
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue