Sorry, hit send by accident. I meant to say:
do_something(v) *if* v != INCONVENIENT_SENTINEL *else break*
-- Carl Smith
[email protected]
On 21 May 2018 at 13:37, Carl Smith <[email protected]> wrote:
> v = get_something()
>
> while v != INCONVENIENT_SENTINEL:
>
> do_something(v)
>
> v = get_something()
>
>
> I'd personally go with:
>
> while True:
> v = get_something()
> if v != INCONVENIENT_SENTINEL: break
> do_something(v)
>
> But it's not much different. I'd really like to be able to use jump
> statements
> in ternary expressions, like:
>
> do_something(v)
>
> But that's another story.
>
> -- Carl Smith
> [email protected]
>
> On 21 May 2018 at 13:22, Juancarlo Añez <[email protected]> wrote:
>
>>
>> while ((v = get_something()) != INCONVENIENT_SENTINEL)
>>> do_something(v);
>>>
>>
>>
>> The current pattern in Python would be something like:
>>
>> v = get_something()
>>
>> while v != INCONVENIENT_SENTINEL:
>>
>> do_something(v)
>>
>> v = get_something()
>>
>> With "as" allowed in "while", they pattern might be:
>>
>> while get_something() as v:
>>
>> if v == INCONVENIENT_SENTINEL:
>>
>> break
>>
>> do_something(v)
>>
>>
>> The discussion isn't over, so it could also be:
>>
>> while (get_something() as v) != INCONVENIENT_SENTINEL:
>>
>> do_something(v)
>>
>>
>> Cheers,
>>
>> --
>> Juancarlo *Añez*
>>
>> _______________________________________________
>> Python-ideas mailing list
>> [email protected]
>> https://mail.python.org/mailman/listinfo/python-ideas
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
>>
>
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/