zeitbach.com

Rust-like Result type for Python

TIL: This library implements a Rust-like Result type for Python 3.

It plays nicely with mypy and has a similar interface as Rust’s Result. You can even use Haskell-inspired do notation:

result: Result[int, str] = do(
    Ok(x + y)
    for x in Ok(1)
    for y in Ok(2)
)

However, this might alienate your Python colleagues, so use with care.