[Python-ideas] Re: is a

2020-05-01 Thread Jonathan Goble
On the subject of custom infix operators, there are at least two packages on PyPI that allow you to do this already: https://pypi.org/project/funcoperators/ https://pypi.org/project/infix/ On Sat, May 2, 2020 at 12:51 AM Steven D'Aprano wrote: > On Fri, May 01, 2020 at 07:41:57PM -0700, Andrew

[Python-ideas] Re: is a

2020-05-01 Thread Steven D'Aprano
On Fri, May 01, 2020 at 07:41:57PM -0700, Andrew Barnert wrote: > The most obvious way to do it is borrowing straight out of Haskell, so this: > > x `spam` y > > … compiles to exactly the same code as this: > > spam(x, y) I really, really want to like that syntax, but I can't. The back

[Python-ideas] Re: is a

2020-05-01 Thread Guido van Rossum
I guess I need to remind folks about the reasons why infix operators are useful. It's not (primarily) about the lack of parentheses or the resemblance to English (oh horror). It's about the *associative property*. For example, it's a good idea to use a binary operator for string concatenation, sin

[Python-ideas] Re: is a

2020-05-01 Thread Andrew Barnert via Python-ideas
On May 1, 2020, at 15:35, Steven D'Aprano wrote: > > but if it is all functions, then I think you have no choice but to > either live with it or shift languages, because the syntax for functions > is too deeply baked into Python to change now. Actually, I’m pretty sure Python could add infix c

[Python-ideas] Re: is a

2020-05-01 Thread Steven D'Aprano
Hi Gavin, You have Reply To set to your personal email address instead of allowing replies to go to the list for everyone to contribute to the discussion. Was that intentional? On Fri, May 01, 2020 at 04:53:31PM -, gbs--- via Python-ideas wrote: > In cases where it makes sense to do expli

[Python-ideas] Re: is a

2020-05-01 Thread Andrew Barnert via Python-ideas
On May 1, 2020, at 10:27, gbs--- via Python-ideas wrote: > > In cases where it makes sense to do explicit type checking (with ABCs or > whatever), I really detest the look of the isinstance() function. > > if isinstance(thing, Fruit) and not isinstance(thing, Apple): > > Yucky. I think it’s

[Python-ideas] Re: is a

2020-05-01 Thread Steele Farnsworth
`yield from` is a case where two keywords are used together to do something new, but they're both keywords independently of each other. If `a` can be variable or a keyword, we'd have to decide when `x is a y` is using `a` as a keyword and when it's using it as a variable. I don't think introducing

[Python-ideas] Re: is a

2020-05-01 Thread Soni L.
On 2020-05-01 2:46 p.m., Steele Farnsworth wrote: So this would make `a` a new keyword. I don't think that could be added into python 4 at the earliest because it would immediately break all code for which `a` is a variable name. we could have keyphrases instead of keywords, tbh. I can ap

[Python-ideas] Re: is a

2020-05-01 Thread Steele Farnsworth
So this would make `a` a new keyword. I don't think that could be added into python 4 at the earliest because it would immediately break all code for which `a` is a variable name. I can appreciate wanting to make simple operations easy to read, though I think this relies too much on understanding