[Tutor] Ending a loop with a condition not at the top

Ben Finney ben+python at benfinney.id.au
Mon Jul 21 05:10:34 CEST 2014


Marc Tompkins <marc.tompkins at gmail.com> writes:

> Seriously, though, how is
> 1) Do {this} forever, until something happens that I'll tell you about
> later
>
> better than
> 2)  Do {this} until this condition, which I'm telling you about RIGHT
> NOW, changes
> ?

Here's how:

The first of them is already implemented in Python, and works well
enough for the purpose. This is a significant benefit the other lacks.

The second one is not implemented in Python, and there are no successful
proposals (which, by the way, are better discussed at the Python Ideas
forum <URL:https://mail.python.org/mailman/listinfo/python-ideas>) to
implement them in a way that justifies the cost of adding it to the
language.

What are you asking for? If you want someone to agree that a ‘while
True: … break’ is not as aesthetically pleasing as it might be ideally:
yes, I agree. It is not perfect. Take that confirmation and be content.

If, on the other hand, you are asking – as your words imply – for the
currest state of affairs to be justified: you already have that. The
justification is: it works *now*, well enough that any alternative so
far proposed is not sufficiently better to displace it within Python.

If you want to propose an improvement to Python, feel free to take it up
at the Python Ideas forum. But do your research first on what a change
to the language would mean – what you're thereby asking the Python
developers and community to accept – and the burden such proposals need
to meet in order to be accepted.

-- 
 \     “I got some new underwear the other day. Well, new to me.” —Emo |
  `\                                                           Philips |
_o__)                                                                  |
Ben Finney



More information about the Tutor mailing list