[issue47202] Feature request: Throw an error when making impossible evaluation against an empty list

Eric V. Smith report at bugs.python.org
Sat Apr 2 12:40:10 EDT 2022


Eric V. Smith <eric at trueblade.com> added the comment:

As Jelle says, this can't be a runtime Exception.

At best mypy or a linter could make iterating over an known empty list (like a literal []) a warning, not an error as suggested by the OP. I sometimes "comment out" loops by doing something like:

for i in []: # long_list_returning_function():
    # lots of code here

I do this just to avoid re-indenting everything if I want to skip the loop during development.

----------
nosy: +eric.smith

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47202>
_______________________________________


More information about the Python-bugs-list mailing list