How should one implement ternary (3 valued) logic in python?
21:06 16 Apr 2026

See wiki article. I have a project that very naturally wants properties which are True, False, or ??. I would like to:

  1. use logical operators is, or, and, and not as usual

  2. stay relatively self-contained, ideally standard lib

I expected to be able to use None, but unfortunately None or False and False or None evaluate to different things (only one of which is what I wanted). What can I do?

I've considered creating a custom 'unknown' class, but I can't overwrite the logical operator behavior.

I've found external libraries like trinary, but they use the |,^,& syntax instead.

I note this is the logic of a NULL value in SQL, so presumably practices to mimic that behavior would work here.

python