# Taken partially from https://github.com/kennknowles/python-either from abc import ABC, abstractmethod class Either(ABC): def __init__(self, v): self._v = v @property def value(self): return self._v @property @abstractmethod def is_left(self) -> bool: pass @property @abstractmethod def is_right(self) -> bool: pass class Left(Either): @property def is_left(self) -> bool: return True @property def is_right(self) -> bool: return False class Right(Either): @property def is_left(self) -> bool: return False @property def is_right(self) -> bool: return True