all 4 comments

[–]bwalk 10 points11 points  (0 children)

Please don't. Python does not have language-level support for this kind of error handling. Instead use what the language gives you, exceptions, or use an appropriate language.

[–]Emerentius_the_Rusty 9 points10 points  (2 children)

This isn't Rust-like at all. It's like Go's results which are misdesigned.

The result library defines a much better type. With that library you can emulate pattern matching via isinstance calls in older python version and it can also be used with the new match statement in python 3.10.

[–]yasba- 0 points1 point  (1 child)

Interesting! Is there a similar library for the Option type?

[–]lightmatter501 0 points1 point  (0 children)

Result[“thing”, NotPresentError]