[Python-ideas] "while:" for the loop

Jonathan Fine 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.

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).

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:
> https://mail.python.org/pipermail/python-dev/2005-July/054914.html
> Idea for the "loop" keyword:
> https://mail.python.org/pipermail/python-ideas/2014-June/028202.html
> (followed by the same suggestion from @Random832:
> https://mail.python.org/pipermail/python-ideas/2014-June/028220.html)
> Somewhat related PEP (rejected) + discussion links inside:
> https://legacy.python.org/dev/peps/pep-0315/
> (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:
> https://mail.python.org/pipermail/python-list/1999-April/002557.html
> https://mail.python.org/pipermail/python-list/1999-May/008535.html
> Another one:
> https://mail.python.org/pipermail/python-list/2000-December/029972.html
> ( Particularly this:
> https://mail.python.org/pipermail/python-list/2000-December/052694.html
> )
> Yet another "1" vs "True" debate:
> https://mail.python.org/pipermail/python-list/2012-January/618649.html
> New era:
> https://mail.python.org/pipermail/python-list/2017-April/721182.html
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/

More information about the Python-ideas mailing list