In article <[email protected]>,
Chris Angelico <[email protected]> wrote:
> while (var = func())
> {
> ....
> }
>
> In Python, that gets a lot clunkier. The most popular way is to turn
> it into an infinite loop:
>
> while True:
> var = func()
> if not var: break
> ....
Or turn it into a generator:
def funcinator():
while True:
var = func()
if var:
yield var
else:
break
for var in funcinator():
....
That certainly makes your mainline code cleaner, but it's a lot of crud
when all you really wanted to write was:
while func() as var:
....
--
https://mail.python.org/mailman/listinfo/python-list