I’ll be the first person to admit I have no idea what postmodernism actually means, but it sounds cool for an article on error-handling (or rather how to prevent them from happening in the first place), and I would argue that the facilities (post?)modern Python provides us for doing so are pretty damn cool.
Recently, an acquaintance of mine posed this question on a message board we both participate in:
okay nerds what do you call a union-type with three states?
so I was writing a Maybe implementation (in python) to deal with a processing pipeline, but then it turned into an Either, and then it turned into something with three states
basically there’s either 1) the final value, 2) no value but a known error occurred, 3) no value but an unknown error occurred
the final states could be: 1) hey it succeeded, here’s the object’s id 2) no value but your json blob was missing a required attribute (or some other known error), or 3) we encountered an error that the programmer didn’t forsee
To which another strapping young gentleman replied:
if it were Rust you could enum your errors
Well, truth be told, I feel like I probably know about as little about fp as I do about postmodernism, but I thought this was an interesting question and I know that Python’s standard library does, actually, provide us Enums ┬─┬ ノ( 0