On Sun, Jul 22, 2018 at 11:22 PM, Grégory Lielens <gregory.liel...@gmail.com> wrote: > The ?? operator is probably the less scary one regarding legibility, and in > guessing (or remembering) what it exactly does... > Well, at least I think I understand what it does exactly, but if I'm not > wrong there, what it does is also quite simple and minimal. > > A function returning it's first non-None argument (or None, if all args are > None) will provide the same functionality, with not much typing. You have > parenthesis for the call, but you will probably need them anyway to group > things, for correcting precedence, or helping the reader to parse your > expression even if precedence was right. > You have an extra call, so ?? may be more efficient...maybe. > > Is that a reason enough, together with a few letters saved typing, to > introduce ?? ? Not for me...
You forget that the operator will *short-circuit*. It will not evaluate the second argument if the first argument is None. You cannot do this with a function, other than with a hack like a lambda function. THAT is reason enough for an operator. ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/