[Python-ideas] PEP 505: None-aware operators
Antoine Pitrou
solipsis at pitrou.net
Thu Jul 19 05:21:19 EDT 2018
On Thu, 19 Jul 2018 19:11:33 +1000
Chris Angelico <rosuav at gmail.com> wrote:
> On Thu, Jul 19, 2018 at 4:06 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> > Chris Angelico wrote:
> >>
> >> I'd love to hear an explanation of WHY this doesn't look like Python
> >> any more. For instance, is the + operator somehow wrong for Python,
> >> and it should have been the word "add"?
> >
> >
> > There's a very long tradition of using the symbol "+" to
> > represent addition, so it's something most people are
> > familiar with. There's no such tradition for the new
> > operators being proposed.
>
> Okay. What about bitwise operators, then? They don't have centuries of
> mathematical backing to support them, yet it isn't considered
> "unpythonic" to have &|^~ peppering our code.
They have decades of widespread presence in other programming
languages, though.
> Coalescing None to a value is _at least_ as common as
> performing bit manipulations in integers.
Certainly, but spelling that as a "?*" operator is a syntactical
novelty.
Consider that for the ternary operator, Python chose "B if A else C"
over "A ? B : C", even though the latter had precedent in several
languages.
Regards
Antoine.
More information about the Python-ideas
mailing list