Skip to content

Instantly share code, notes, and snippets.

@veber-alex
veber-alex / py_result.py
Created May 15, 2021 20:06
Python Result type simulating Rust's Result enum.
from typing import Generic, Optional, TypeVar
from abc import ABC, abstractmethod
from dataclasses import dataclass
T = TypeVar('T')
E = TypeVar('E')
class Result(Generic[T, E], ABC):
@abstractmethod
proc main() {
do yeet lol;
}
abstract fn foo() {}