Message336890
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. |
|
Date |
User |
Action |
Args |
2019-03-01 04:29:31 | terry.reedy | set | recipients:
+ terry.reedy, matrixise, xtreak, wlohu |
2019-03-01 04:29:31 | terry.reedy | set | messageid: <1551414571.92.0.317768098585.issue36066@roundup.psfhosted.org> |
2019-03-01 04:29:31 | terry.reedy | link | issue36066 messages |
2019-03-01 04:29:31 | terry.reedy | create | |
|