dimanche 26 avril 2020

Short statement for if-not-none-then-none-else-default [duplicate]

Env: Python 3.8

Is there a shorthand statement for something like this:

def if_not_none_then_none_else_default(some_value, default):
    if some_value:
        return None
    else:
        return default

Aucun commentaire:

Enregistrer un commentaire