on writing a while loop for rolling two dice

Avi Gross avigross at verizon.net
Mon Sep 6 20:41:20 EDT 2021


I hate to quibble but as almost anything in Python can evaluate to being
truthy, a command like

while "never"

evaluates to true as the string is not empty.

I meant a generator like

>>> def boring():
	while True: yield()

	
>>> for _ in boring():
	print("repeating ...")

The above gives me a nice infinite loop, with the second one looking like a
normal loop but actually doing nothing much.

-----Original Message-----
From: Python-list <python-list-bounces+avigross=verizon.net at python.org> On
Behalf Of 2QdxY4RzWzUUiLuE at potatochowder.com
Sent: Monday, September 6, 2021 8:28 PM
To: python-list at python.org
Subject: Re: on writing a while loop for rolling two dice

On 2021-09-06 at 20:11:41 -0400,
Avi Gross via Python-list <python-list at python.org> wrote:

> And in the python version, has anyone made a generator that returned 
> NULL or the like so you can say uselessly:
> 
> for ( _ in forever() ) ...

    while "forever":
        ...
--
https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list