[Python-ideas] Null coalescing operators

Chris Angelico rosuav at gmail.com
Tue Sep 22 02:44:13 CEST 2015


On Tue, Sep 22, 2015 at 10:34 AM, Matthias Bussonnier
<bussonniermatthias at gmail.com> wrote:
> On Mon, Sep 21, 2015 at 2:48 PM, Guido van Rossum <guido at python.org> wrote:
> As we are in the process of writing a PEP and  uses of ?/?? in other languages,
> why not speak about thecurrent usage of `?` / `??` in the Python community ?
>
> Can the PEP include the fact that `? and `??` have been in use in the Scientific
> Python community for 10 to 14 years now, and that any Scientific Python user who
> have touched IPython will tell you that ? and ?? are for getting help.
> (?? try to pull the source, while ? does not, but let's not get into details).
>
> This include the fact that any IDE (like spyder) which use IPython under
> the hood have this feature.
>
> I also want to note that the use of `?`/`??` is not present to just being or end
> of identifiers as it can also be used use to search for names:
>
>> In [1]: *int*?
>> FloatingPointError
>> int
>> print
>
> But this usage is not as widespread as extracting help about objects,
> and seem less relevant, though I'm not sure:
>
>> In [10]: ?Float*Error
>> FloatingPointError
>>
>> In [12]: Uni*Error?
>> UnicodeDecodeError
>> UnicodeEncodeError
>> UnicodeError
>> UnicodeTranslateError
>
> Please take these fact into consideration when making a
> decision/writing the Pep.

Are there any uses like this that would involve a question mark
followed by some other punctuation? The main proposal would be for
x?.y and similar; if "x ?? y" can't be used because of a conflict with
ipython, I'm sure it could be changed ("x ?! y" would be cute).

ChrisA


More information about the Python-ideas mailing list