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

2019-06-04 Thread Stephen J. Turnbull
Chris Angelico writes: > ## New "unless" construct for list displays and argument lists ## > > Inside a list/dict/set/tuple display, or inside an argument list, > elements can be conditionally omitted by providing a predicate. > > lst = [f1(), f3() unless f2(), f4()] Not a fan of this in

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

2019-06-03 Thread Steven D'Aprano
On Mon, Jun 03, 2019 at 08:57:22PM -0400, James Lu wrote: > `if-unless` expressions in Python > > if condition1 expr unless condition2 > > is an expression that roughly reduces to > > expr if condition1 and not condition2 else EMPTY Then the "unless" clause is superfluorous and we can

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

2019-06-03 Thread Chris Angelico
On Tue, Jun 4, 2019 at 10:58 AM James Lu wrote: > > `if-unless` expressions in Python > > if condition1 expr unless condition2 > > is an expression that roughly reduces to > > expr if condition1 and not condition2 else EMPTY > > This definition means that expr is only evaluated if

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

2019-06-03 Thread MRAB
On 2019-06-04 01:57, James Lu wrote: `if-unless` expressions in Python     if condition1 expr unless condition2 is an expression that roughly reduces to     expr if condition1 and not condition2 else EMPTY This definition means that expr is only evaluated if `condition1 and not

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

2019-06-03 Thread James Lu
`if-unless` expressions in Python if condition1 expr unless condition2 is an expression that roughly reduces to expr if condition1 and not condition2 else EMPTY This definition means that expr is only evaluated if `condition1 and not condition2` evaluates to true. It also means `not