[Python-ideas] Null coalescing operators

MRAB python at mrabarnett.plus.com
Wed Sep 23 04:43:50 CEST 2015

On 2015-09-23 02:21, Fernando Perez wrote:
> On 2015-09-22 03:59:07 +0000, Andrew Barnert via Python-ideas said:
> I'm not saying they have a right to expect/demand that Guido never
> change his mind about anything anywhere ever, just that maybe they get a
> little extra consideration on backward compatibility with their use of ?
> than with their use of ! or % (which have been in use as operators or
> parts of operators for decades).
> I just wanted to quickly comment on what my original stance was
> regarding IPython's extensions to the base Python language.This was
> where I stood as I made decisions when the project was basically just
> me, and over time we've mostly adopted this as project policy.
> We fully acknowledge that IPython has to be a strict superset of the
> Python language, and we aremost emphatically *not* a fork of the
> lanugage intended to be incompatible. We've added some extensions by
> hijacking a few characters that are invalid in the base language for
> thigns we deemed to be useful while working interactively, but we always
> accept that, if the language moves in our direction, it's our job to
> pack up and move again to a new location.
> In fact, that already happened once: before Python 2.4, our prefix for
> "magic functions" was the @ character, and when that was introduced as
> the decorator prefix, we had to scramble.We carefully decided to pick %,
> knowing that an existing binary operator would be unlikely to be added
> also as a new unary prefix.
> Now, accepting that as our reality doesn't mean that at least we don't
> want to *inform* you folks of what our uses are, so that at least you
> can consider them in your decision-making process.Since in some cases,
> that means there's an established ~ 15 years of a community with a habit
> of using a particular syntax for something, that may be confused if
> things change.So at least, we want to let you know.
> Due precisely to these recent conversations (I had a very similar thread
> a few days ago with Nick about the ! operator, which we also use in all
> kinds of nasty ways), we have started documenting more precisely all
> these differences, so the question "where exactly does IPython go beyond
> Python" can be answered in one place.You can see the progress here:
> https://github.com/ipython/ipython/pull/8821
> We hope this will be merged soon into our docs, and it should help you
> folks have a quick reference for these questions.
> Finally, I want to emphasize that these things aren't really changing
> much anymore, this is all fairly stable.All these choices have by now
> stabilized, we only introduced the @ -> % transition when python 2.4
> forced us, and more recently we introduced the notion of having a
> double-%% marker for "cell magics", but that was ~ 4 years ago, and it
> didn't require a new character, only allowing it to be doubled.
 From the examples I've seen, the "?" and "??" occur at the end of the line.

The proposed 'operators' "?.", "?[", "?(" and "??" wouldn't occur at
the end of the line (or, if they did, they'd be inside parentheses,
brackets, or braces).

So is there really a conflict, in practice?

More information about the Python-ideas mailing list