Lightweight, generic result type à la Rust. (Sometimes you just want errors as values.)
Note: There is a full-on package that does this, with all the other Rust niceties of
.unwrap_or()
, etc. But if all you need is the basics, this is a zero-dependency approach in like 8 lines of actual code.
from dataclasses import dataclass