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 <mailto: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
<mailto:python-ideas@python.org>
To unsubscribe send an email to python-ideas-le...@python.org
<mailto:python-ideas-le...@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/YKLNQXONLLZ7OXEMUHXF5HD4PCX4SNVT/
Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@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/PQSJ6PSRS3JZZUV7CRRKRSGJAPVBYP6G/
Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@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/JFSNV7FAKLMTZWQDHJWPX3ZSMKVHA6V3/
Code of Conduct: http://python.org/psf/codeofconduct/