[issue36066] Add `empty` block to `for` and `while` loops.

Terry J. Reedy report at bugs.python.org
Thu Feb 28 23:29:31 EST 2019


Terry J. Reedy <tjreedy at udel.edu> added the comment:

Syntax changes need PEPs.  By default, syntax changes are rejected.  This is especially true for new keywords, as any acceptible word will already be in use, and hence its introduction *will* break code.

We are still having issues over having temporarily made 'async' and 'await' 'semi-keywords' (for 2 versions) to smooth out breakage.  So new keywords must enable something previously difficult.  But implementing the 'empty' idea is fairly trivial, as demonstrated in the initial post.

A third alternative is a peak(iterator) class with a __bool__ method.  I posted one once, probably on python-list.  But the extra overhead every iteration must be larger than the simple assignment, which is so fast one should not worry about it.  I suspect the flag also beats the chain alternative.
---

[More opinionated than the above ...]

Calling what is easy and works today 'non-idiomatic' is nearly pure opinion and not persuasive as a rhetorical device.

The complicated rules for else-never interaction to be far more 'anti-idiomatic' from a comprehension point of view.  In any case, a flag allows easy, flexible, and precise ordering of never, something, and either-way code.

----------
nosy: +terry.reedy
resolution:  -> postponed
stage:  -> resolved
status: open -> closed

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


More information about the Python-bugs-list mailing list