On 12/11/2014 9:21 PM, Nelson Crosby wrote:
I was thinking a bit about the following pattern:

value = get_some_value()
while value in undesired_values:
     value = get_some_value()

This is do_while or do_until.  In Python, write it as do_until in this form.

while True:
    value = get_some_value()
    if value not in undesired_values:
        break

I've always hated code that looks like this. Partly due to the repetition,
but partly also due to the fact that without being able to immediately
> recognise this pattern, it isn't very readable.

The repetitiion is easily eliminated.

value = get_some_value() while value in undesired_values()

Forget this, or anything like it, as a 'serious' proposal.

--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to