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

2019-06-25 Thread Jonathan Goble
*de-lurks* On Wed, Jun 26, 2019 at 1:21 AM Steven D'Aprano wrote: > > On Mon, Jun 24, 2019 at 12:37:48PM -0700, Andrew Barnert wrote: > > > And the one-time hassle of figuring out how to configure your MUA, or > > even switching to a better one > > "Better" is subjective, and just because a

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

2019-06-25 Thread Steven D'Aprano
On Mon, Jun 24, 2019 at 12:37:48PM -0700, Andrew Barnert wrote: > Since you bring up “feeble mail clients”: > > Good mail clients can be configured to collapse and expand quotes, and > to automatically start long nested quotes collapsed. Indeed you are correct, and my own mail client

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

2019-06-25 Thread Rhodri James
On 24/06/2019 20:50, Jonathan Fine wrote: I'm concerned that in this thread, and elsewhere, we're not paying sufficient attention to https://en.wikipedia.org/wiki/Cognitive_load. I was under the impression that most of the counter-arguments could be rephrased as "this increases cognitive load

[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

[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

[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

[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

[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

[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 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

[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

[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

[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

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

2019-06-23 Thread Chris Angelico
On Mon, Jun 24, 2019 at 2:44 PM Andrew Barnert via Python-ideas wrote: > But dict displays, that could be confusing. Do you have to pass-value the > key, or the value, or either of the two, or both consistently? If the key, > does that short-circuit the value expression? So I think you’re

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

2019-06-23 Thread Andrew Barnert via Python-ideas
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 not condition2 else pass >> >> This

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

2019-06-23 Thread MRAB
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 not condition2 else pass This seems a lot more tenable than the original proposal. The “unless”

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

2019-06-06 Thread Robert Vanden Eynde
> print([ > 3, > if False never_called() unless False, > if False never_called() unless False, > 2, > if True 5 unless False, > 4 >]) # => [3, 2, 5, 4] Do you mean this ?Currently what I use is the `*` operator on lists : ``` print([ 3, ] +