`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 that possibility is worth the effort. On Fri, May 1, 2020 at 2:13 PM Soni L. <fakedme+py@gmail.com> wrote:
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 appreciate wanting to make simple operations easy to read, though I think this relies too much on understanding English and wouldn't be intuitive for people who aren't English speaking. I am native English speaking so I wouldn't know for sure, but I think accepting that "or" is the same as "||" is an easier jump to make than "x is a y" being a construct for indicating that x belongs to the y class.
If you need this English-style syntax, I believe `type(x) is y` is guaranteed to be True if x is exactly of the y type and not one of its super classes.
On Fri, May 1, 2020, 1:27 PM gbs--- via Python-ideas < python-ideas@python.org> 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.
What I really want to write is:
if thing is a Fruit and thing is not an Apple:
and after thinking about it on and off for a while I wonder if it might indeed be possible to teach the parser to handle that in a way that eliminates almost all possible ambiguity with the regular "is", including perhaps 100% of all existing standard library code and almost all user code?
Maybe this has been considered at some point in the past? The "is [not] a|an" proposal would at least be a strong contender for "hardest thing to search for on the internet" lol.
Thanks!
Gavin _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/YKLNQX... Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.orghttps://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/PQSJ6P... Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/JFSNV7... Code of Conduct: http://python.org/psf/codeofconduct/