A simple Maybe (Option) type for Python 3 inspired by Rust, fully type annotated.
Latest release:
$ pip install rustedpy-maybeLatest GitHub master branch version:
$ pip install git+https://github.com/rustedpy/maybeExperimental. API subject to change.
The idea is that a possible value can be either Some(value) or
Nothing(), with a way to differentiate between the two. Some and
Nothing are both classes encapsulating a possible value.
Example usage,
from maybe import Nothing, Some
o = Some('yay')
n = Nothing()
assert o.unwrap_or_else(str.upper) == 'yay'
assert n.unwrap_or_else(lambda: 'default') == 'default'MIT License