[Python-ideas] Special keyword denoting an infinite loop

Chris Angelico rosuav at gmail.com
Sat Jun 28 12:07:17 CEST 2014


On Sat, Jun 28, 2014 at 6:04 PM, Thomas Allen <jsbfox at gmail.com> wrote:
> I personally find it much prettier than while True or while 1.

One common technique I've seen is the self-documenting infinite loop:

while "more work to be done":
    get_work()
    do_work()

If you're worried about the prettiness of "while True", this might
help. Since any non-empty string counts as true, this can add a bit
more information without disrupting the loop itself.

ChrisA


More information about the Python-ideas mailing list