[Python-ideas] "while:" for the loop
jfine2358 at gmail.com
Tue Oct 2 07:31:35 EDT 2018
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.
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.
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).
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
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!
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.
On Sat, Sep 29, 2018 at 4:58 AM Mikhail V <mikhailwas at gmail.com> wrote:
> I put the list of related discussion here, just in case.
> Same suggestion:
> Idea for the "loop" keyword:
> (followed by the same suggestion from @Random832:
> Somewhat related PEP (rejected) + discussion links inside:
> (I've meditated a bit on this - but could not get what was
> actually the point of that idea.)
> Plus some other related discussions, maybe not directly related,
> but something along the lines might be interesting.
> An old and lively one:
> Another one:
> ( Particularly this:
> Yet another "1" vs "True" debate:
> New era:
> Python-ideas mailing list
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
More information about the Python-ideas