Forbid to use `continue` in `finally`
See original GitHub issueRule request
Thesis
This code is now allowed:
for some in range(10):
try:
func(some)
finally:
continue
Why would you do that?
Putting any control statements in finally
is a terrible practice.
We should not allow it.
It was added in python3.8
: https://www.python.org/downloads/release/python-381/
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Why is `continue` not allowed in a `finally` clause in Python?
The use of continue in a finally-clause is forbidden because its interpretation would have been problematic.
Read more >PEP 601 – Forbid return/break/continue breaking out of finally
The use of return , break and continue within a finally suite leads to behaviour which is not at all obvious.
Read more >Why continue statement cannot be used inside finally block?
This post explores why continue statement cannot be present inside finally block. Now for our understanding let's assume that we can write continue...
Read more >Warn about continue/return/break in finally block #99 - GitHub
I reported this issue originally to pyflakes but they decided that is it not an error, and hence it should better be flagged...
Read more >ERR04-J. Do not complete abruptly from a finally block
Never use return , break , continue , or throw statements within a finally block. When program execution enters a try block that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure! Feel free to ask for help.
We can combine them into one:
continue
andbreak