Re: [Python-ideas] if we were to ever shorten `A if A else B` (was: PEP 505: None-aware operators)

2018-07-21 Thread Grégory Lielens
Coming from the @ side (I was strong +1 on this), I have troubles seeing the 
real benefits from ?? (And even more from associates): did we really have long 
and complex expressions where the compactness of an operator would help? 

Operators are inherently obscure (except for those that are learnt in 
elementary school), but they help when you combine multiple operators and 
benefit from their precedence rules. There you can benefit from them, even if 
explicit it's better than implicit...
It was the case for @, and even with proofs of long formulas, and a history of 
matrix algebra from hundreds of years before computing science, the resistance 
was strong: a majority of non-numpy users resisted it, saying a function 
matmul(A,B) was good enough and A@B would bring nothing.
It was eventually accepted, 7 or so years after the initial proposal, through 
another PEP, when relative weight of numpy community was probably larger.
So i'd like to see examples of long expressions that would really benefit groin 
using an very specific operator. At this point, the explicitness of "a if a is 
not None else []" wins, by a long shot...___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


Re: [Python-ideas] if we were to ever shorten `A if A else B` (was: PEP 505: None-aware operators)

2018-07-21 Thread Chris Barker - NOAA Federal via Python-ideas
> my vote would go to `A otherwise B` since it's unambiguous, the case you care 
> about the state  of comes first, and it doesn't trip your brain up looking 
> for 'if'. :)

And I’d hope “otherwise” is a rare variable name :-)

- CHB

>
> ___
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] if we were to ever shorten `A if A else B` (was: PEP 505: None-aware operators)

2018-07-20 Thread Brett Cannon
On Thu, 19 Jul 2018 at 14:29 Steve Dower  wrote:

> [SNIP]
>
> * "We could have 'else', we don't need '??'"
>
> This is the "a else 'default'" rather than "a ?? 'default'" proposal,
> which I do like the look of, but I think it will simultaneously mess
> with operator precedence and also force me to search for the 'if' that
> we actually need to be comparing "(a else 'default')" vs. "a ??
> 'default'"::
>
>  x = a if b else c else d
>  x = a if (b else c) else d
>  x = a if b else (c else d)
>

The searching for the 'if' also throws me with this proposal. I think
someone else proposed `A unless B` but I always prefer knowing upfront what
I'm working with, not later by having to read farther along.

Personally, if the `A?? B` is the part people like but hate the syntax then
my vote would go to `A otherwise B` since it's unambiguous, the case you
care about the state  of comes first, and it doesn't trip your brain up
looking for 'if'. :)
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/