3 ms·
If python used C style loops rather than pushing iterators/generators so hard, I would buy that reasoning. But where's the conditional statement in `for i in r
by reificator 8y ago
If python used C style loops rather than pushing iterators/generators so hard, I would buy that reasoning. But where's the conditional statement in `for i in range(0,10)`?
Now, clearly there is a check to see if it's still producing values. But it's intentionally hidden from a surface-level reading of the code.
Naming a control structure `else` when it intentionally does not have a clear conditional tied to it is odd to say the least.
But it's worse than that- the else clause is supposed to be the normal flow of the program. Programming introductions (fresh in the minds of many who use Python as it's targeted as user-friendly) often stress the fact that in an if/else statement only one or the other block is executed. But this flips that idea upside-down.
- mlthoughts2018 8y agoIt would be the implicit StopIteration exception from the resulting iterator, but I completely agree this can easily be seen as inconsistent / surprising, which is among the reasons why I don’t like it.
- reificator 8y agoThanks for the clarification, I don't use python very often myself. That does underscore that there's really not a normal conditional there though.