top | item 46183779 (no title) martinflack | 2 months ago It could've easily been defined that the else branch runs if the while condition never had a true value at all. In fact, I think that's more intuitive. discuss order hn newest thaumasiotes|2 months ago What are you trying to say? It is defined that way. And the example I provided above makes that completely explicit.But here, from the official documentation:> if the expression is false (which may be the first time it is tested) the suite of the else clause, if present, is executed and the loop terminates.https://docs.python.org/3/reference/compound_stmts.html#the-...
thaumasiotes|2 months ago What are you trying to say? It is defined that way. And the example I provided above makes that completely explicit.But here, from the official documentation:> if the expression is false (which may be the first time it is tested) the suite of the else clause, if present, is executed and the loop terminates.https://docs.python.org/3/reference/compound_stmts.html#the-...
thaumasiotes|2 months ago
But here, from the official documentation:
> if the expression is false (which may be the first time it is tested) the suite of the else clause, if present, is executed and the loop terminates.
https://docs.python.org/3/reference/compound_stmts.html#the-...