[Python-ideas] "while:" for the loop
Rhodri James
rhodri at kynesim.co.uk
Tue Oct 2 10:26:34 EDT 2018
On 02/10/18 12:31, Jonathan Fine wrote:
> Mikhail V has suggested "while:" as a shorthand for "while True:".
> He's also provided a helpful list of URLs for related discussion. I'd
> like to suggest another approach.
Before we hare off into the middle distance, could you show that there
is a problem that needs to be addressed here? I killfiled Mikhail a
long time ago, so I haven't actually seen any justification here beyond
"I don't want to have to type five more characters."
> My suggestion is to improved documentation and help. For me a search for
> python "while True"
> produces as the top result https://wiki.python.org/moin/WhileLoop.
>
> Please take a look at this page. I don't think it's suitable for
> novices. In particular, about 25% of the page compares "while 1:" to
> "while True:" and changes between Python2 and Python3.
Is it intended solely for novices?
>
> Searching for
> site:docs.python.org "while True"
> produces as top result https://docs.python.org/3/tutorial/controlflow.html.
>
> Please also look at this page. It has two examples of "while True:",
> but does not say that "while True:" means loop forever (unless there
> is a break or an exception).
This is an invidious example. "while" is actually introduced on the
previous page, as the first paragraph says. Expecting a statement of
the blindingly obvious here is inappropriate, surely. (And yes, my
experience with early teens is that it *is* blindingly obvious.)
>
> Today I saw https://blog.codeclub.org.uk/2018/06/13/how-to-move-from-scratch-to-python-in-code-club/
>
> On this page, a Code Club volunteer gives as debugging advice
> <quote>
> I use comparisons of Scratch to Python at the beginning, for example
> to explain that ‘while True’ is the same as the ‘Forever’ block. I
> also have some Python cheat sheets which give examples of common
> Python code. Some of the learners find it easier to debug Python than
> Scratch, because Python gives you error messages to indicate what went
> wrong. It’s usually down to spelling errors!
> </quote>
Um, yay? I'm not sure what your point here is. So Scratch has a
Forever block, so what?
> My final URL is https://www.youtube.com/watch?v=QEJ8tE9lAeE.
> This is a 3 minute video: Python For Beginners - How to use a While
> True Loop in Python.
>
> Something that can be done now, which can soon bring benefit to many,
> is to find or write material that will help novices master Python
> idioms such as "while True:". I'm sure the Code Club would like to put
> such material on its web site.
I'm sorry, but I find the idea that idioms like "while True:" need to be
*mastered* a tad patronising. I have genuinely not had to take more
than five minutes to get it through to an uninterested and not
particularly technical 12-year old.
--
Rhodri James *-* Kynesim Ltd
More information about the Python-ideas
mailing list