[Python-ideas] PEP 505: None-aware operators

Giampaolo Rodola' g.rodola at gmail.com
Thu Jul 19 07:34:31 EDT 2018


On Thu, Jul 19, 2018 at 11:22 AM Antoine Pitrou <solipsis at pitrou.net> wrote:
>
> 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.
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/

^
Agreed. To me even bitwise operators "feel" a bit weird when using
them but fortunately they are rare. On the other hand "?" has the
potential to be used (and abused) much more than bitwise operators.
Also I don't consider "since we have X then let's add Y" a valid
enough reasoning.

-- 
Giampaolo - http://grodola.blogspot.com


More information about the Python-ideas mailing list