Sorry if I missed the boat, but only just now saw this PEP.

Glancing through the PEP, I don't see mentioned anywhere the SQL
alternative of having a coalesce() function:
https://www.postgresql.org/docs/9.6/static/functions-conditional.html#FUNCTIONS-COALESCE-NVL-IFNULL

In Python, something like this:

def coalesce(*args):
    for arg in args:
        if arg is not None:
             return arg
    return None

Just drop it into builtins, and voila.   No need for lengthy discussions
about which operator to use because IMHO it needs no operator.

Sure, it's not as sexy as a fancy new operator, nor as headline grabbing,
but it is pretty useful.

Just my 2p.

-- 
Gustavo J. A. M. Carneiro
Gambit Research
"The universe is always one step beyond logic." -- Frank Herbert
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to