The concatenated name reads a little weird. Alternatively, extend the conditional expression syntax.
a = b if None c equivalent to a = b if b is None else c On Thu, Jul 19, 2018 at 9:35 AM, Robert Vanden Eynde <robertv...@gmail.com> wrote: > 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 <cspea...@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.dra...@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@python.org >>> https://mail.python.org/mailman/listinfo/python-ideas >>> Code of Conduct: http://python.org/psf/codeofconduct/ >>> >>> >> _______________________________________________ >> Python-ideas mailing list >> Python-ideas@python.org >> https://mail.python.org/mailman/listinfo/python-ideas >> Code of Conduct: http://python.org/psf/codeofconduct/ >> > > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/