Behavior of the for-else construct
Akkana Peck
akkana at shallowsky.com
Thu Mar 3 17:33:34 EST 2022
computermaster360 writes:
> I want to make a little survey here.
>
> Do you find the for-else construct useful?
No.
> Have you used it in practice?
Once or twice, but ended up removing it, see below.
> Do you even know how it works, or that there is such a thing in Python?
I always have to look it up, because to my mind, "else" implies
it does something quite different from what it actually does.
Which means that even if I worked hard at memorizing what it does,
so I didn't have to look it up, I still wouldn't use it in code,
because I want my code to be easily readable (including by future-me).
for..else makes code difficult to understand by anyone who doesn't
use for..else frequently: they might be misled into misunderstanding
the control flow.
...Akkana
More information about the Python-list
mailing list