Python version of Rust Result Sum Type

I try to implement a Python version of the Result<T, E> sum type in rust which can be used with match/case pattern matching. The pattern matching with sub-patterns like case Err(e) could be implemented in Python with the __match_args__ dunder attribute. This is how Result[T, E] , OK() and Err() defined: 1 import typing 2 3 T = typing.TypeVar('T') 4 E = typing.TypeVar('E') 5 6 class Result[T, E]: 7…