[Python-ideas] PEP 505: None-aware operators: operators ?= and ?? and OR
Robert Vanden Eynde
robertve92 at gmail.com
Thu Jul 19 09:35:17 EDT 2018
If we're about to use a new keyword, it could be infix too:
a = b ifnone c
Although the assignment version looks unusual:
b ifnone= c
Then with the "default b = c" would look like this:
ifnone b = c
Le jeu. 19 juil. 2018 à 15:30, Calvin Spealman <cspealma at redhat.com> a
écrit :
> Operators that only vary by case would be... confusing. I'm not super keen
> on the other syntax (either the ?? or .? operators) but I do think they
> read well in C# where they come from. Different things work in different
> languages, some times.
>
> What about a new keyword: default
>
> So you'd write the above examples like this:
>
> default hi = len(a) # Only executes the assignment if the left-hand is
> None
> default encoding = sys.getdefaultencoding()
>
> On Thu, Jul 19, 2018 at 9:06 AM, Pål Grønås Drange <paal.drange at gmail.com>
> wrote:
>
>> > I've started a subthread, just to discuss the ?= and ?? operators. And
>> > something newish, that I call OR.
>>
>> I would think `||` would be much better.
>>
>> It could be a kind of "semantic or" which could use the aforementioned
>> dunder has_value.
>>
>> -1, though, but to the general None-awareness.
>>
>> Pål
>>
>> _______________________________________________
>> 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/
>>
>>
> _______________________________________________
> 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/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180719/751f9993/attachment.html>
More information about the Python-ideas
mailing list