On 6/24/19 12:32 PM, James Lu wrote:

> I think
>
> print("Remember to wear sunscreen!") if hot_outside unless Weather.is_raining()
>
> Is more readable than
>
> if hot_outside and not Weather.is_raining(): print("Remember to wear sunscreen!")

I disagree, but that's bound to happen in a discussion like this.

> I think the unless syntax would be especially useful when there is a
> series of functions like this.
>
> The general use case would be:
>
> side_effecting_expression if frequent_condition unless rare_condition

Can you clarify "series of functions like this"?  Are the functions the
calls to print?  Are the functions the calls to Weather.is_raining()?

IMO, in a "series of logic like this," the fact that individual bits are
the same should be blindingly obvious.  With line after line of multiple
bits (some side-effecting statement, two conditions, and some keywords),
as opposed to a series of if statements with their associated inddented
suites, I feel that the commonality will get lost.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/JNZ3CGYGCNEHCVIKR7DHINSEJN4DEE5U/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to