Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

IMO Python's equivalent of Rust's Enums would be `typing.Union` [1]. It is more ergonomic and type-safe, and mypy supports type narrowing [2] and exhaustiveness checking on it [3].

[1] https://docs.python.org/3/library/stdtypes.html#types-union

[2] https://mypy.readthedocs.io/en/stable/type_narrowing.html

[3] https://docs.python.org/3/library/typing.html#typing.assert_...



Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: