575
you are viewing a single comment's thread
view the rest of the comments
[-] lime@feddit.nu 6 points 4 days ago* (last edited 4 days ago)

no, the linked table shows how python also returns the first non-falsey result of an a or b expression rather than just giving a boolean. it's useful for initialising optional reference args:

def foo(a: list = None)
    a = a or []

works with and as well.

this post was submitted on 12 Jun 2025
575 points (98.6% liked)

Programmer Humor

24240 readers
2016 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS