-- snip --

An inconsistency that I have been able to notice is this:
someone suggests to remedy the absence of the do-while with:
while True:
      ...
      if condition:
          break
the problem arises if the while has an else of its own because the break
not only blocks the while loop but will also ignore the relative else.


I will try to make my doubt clearer:
if the only way to terminate a 'while True' loop is by using the 'break' statement, why is it allowed to add the 'else' statement which will only contain dead code?

while True:
    break
else:
    print('dead code')
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to