News for hackers. Stuff that matters.
Re:We don’t use Python native enums by brentsch on Friday January 29, 2021 @06:19PM (#25964130)
A key line seems to be buried in the "Summary" at the end of the post: "Python native enums are great for what they were designed to do, but..." Barring tricks I'm unaware of, enums in other popular languages, such as Go and TypeScript, don't support the author's more complex usage either—probably by design.

Out of curiosity, are there languages for which the enum implementation supports and encourages encoding complex data like this?

Re:We don’t use Python native enums by isaac21259 on Friday January 29, 2021 @06:54PM (#25964448)
I think rust encourages encoding data like that.

https://doc.rust-lang.org/rust-by-example/custom_types/enum....

Re:We don’t use Python native enums by rmdashrfstar on Saturday January 30, 2021 @12:16AM (#25966380)
Sum types are the main reason I love writing Rust code. We all miss sum type Enums wherever we go. [0]

[0] https://www.reddit.com/r/rust/comments/l594zl/everywhere_i_g...

Re:We don’t use Python native enums by habitue on Friday January 29, 2021 @09:58PM (#25965580)
Often called sum types, it's really convenient when your language supports both building these kinds of enums as well as destructuring them with pattern matching.

If you don't have destructuring, they're less attractive. There's a proposal to add destructuring to python[1] so we'll see

[1] https://www.python.org/dev/peps/pep-0634/

Re:We don’t use Python native enums by nine_k on Friday January 29, 2021 @06:52PM (#25964441)
Maybe Java? https://docs.oracle.com/javase/tutorial/java/javaOO/enum.htm...

Look how they encode planetary data into the enum of the Solar system planets.

Re:We don’t use Python native enums by remram on Friday January 29, 2021 @06:55PM (#25964469)
Yes, you can search for "tagged union"