[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread Greg Ewing
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!") That's very much a matter of opinion -- I find the second version considerably clea

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread Jonathan Fine
I'm concerned that in this thread, and elsewhere, we're not paying sufficient attention to https://en.wikipedia.org/wiki/Cognitive_load. Adding a feature to a system can increase the cognitive load in learning the system, and it can also reduce the cognitive load in using the system. Sometimes add

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread Andrew Barnert via Python-ideas
On Jun 24, 2019, at 10:27, Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: > > 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 Weat

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread Dan Sommers
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 discu

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread MRAB
On 2019-06-24 17:32, 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 think the unless syntax would be especially useful when there

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread Chris Angelico
On Tue, Jun 25, 2019 at 3:01 AM 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 think the unless syntax would

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread James Lu
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 think the unless syntax would be especially useful when there is a series of functions like this.

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread Steven D'Aprano
Folks, Can I please remind people to trim their quoting? We readers shouldn't have to hit the Page Down key eight or nine times, or scroll down through five or six pages, to see the first new content. (I have a rule: if I haven't reached new content after nine screens of quoting, I give up and

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread MRAB
On 2019-06-24 05:39, Andrew Barnert wrote: On Jun 23, 2019, at 19:57, MRAB wrote: > >> On 2019-06-24 02:43, Andrew Barnert wrote: >> On Jun 23, 2019, at 13:33, MRAB wrote: >> >> > Finally, under "For consideration: alternative syntaxes", my offering would be: >> > > expr if condition1 and n

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread Chris Angelico
On Mon, Jun 24, 2019 at 10:38 PM MRAB wrote: > Well, I suppose it could work with parentheses, but not necessarily in > the way you want/expect. If customer_wants("spam") returns False, then > (quux("spam", "eggs", "sausage", "spam") unless customer_wants("spam")) > could mean ()! (You could say t

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread MRAB
On 2019-06-24 09:23, Chris Angelico wrote:> On Mon, Jun 24, 2019 at 6:03 PM Andrew Barnert wrote: >> >> On Sunday, June 23, 2019, 10:13:07 PM PDT, Chris Angelico wrote: >> >> > The biggest problem with this proposal is the way that, being a >> > syntactic construct, it's going to be non-compo

[Python-ideas] Integer infinity and extended integers

2019-06-24 Thread Neil Girdhar
Now that Python is beginning to embrace type annotations, is it worth revisiting the idea of having extended integers and an integer infinity? I found myself trying to annotate this line: events_to_do: Union[int, float] = math.inf where I am only including float in the union to accommodate math

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread Chris Angelico
On Mon, Jun 24, 2019 at 6:03 PM Andrew Barnert wrote: > > On Sunday, June 23, 2019, 10:13:07 PM PDT, Chris Angelico > wrote: > > > The biggest problem with this proposal is the way that, being a > > syntactic construct, it's going to be non-composable. > > > # Oops, syntax error > > with (some_e

[Python-ideas] Re: `if-unless` expressions in Python

2019-06-24 Thread Andrew Barnert via Python-ideas
On Sunday, June 23, 2019, 10:13:07 PM PDT, Chris Angelico wrote: > The biggest problem with this proposal is the way that, being a > syntactic construct, it's going to be non-composable. > # Oops, syntax error > with (some_expr as q, >         some_other_expr as w):>     pass I don't understan