• stebo02@sopuli.xyz
    link
    fedilink
    arrow-up
    0
    ·
    11 months ago

    Python:

    return a or b

    i like it because it reads like a sentence so it somewhat makes sense

    and you can make it more comprehensive if you want to:

    return a if a is not None else b

    • Turun@feddit.de
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      11 months ago

      This diverges from the OP code snippets if a has the value False.