Introducing a Safe Navigation Operator in Python

Yeah, there would definitely need to be significant iteration on the exact design of a built-in result type.

A couple of notes that occurred to me just in the time since my last post:

  • the safe navigation operators likely would need to be result-aware, so they would compose nicely with methods that were defined as returning results instead of eagerly raising exceptions
  • rather than reraising the original exception directly, or raising an entirely new exception with no link to the original, results would need to use the raise new_exc from saved_exc syntax, so both tracebacks would be reported correctly

And just to confirm, the library you’re referring to is the one mentioned in
Introduce Result class to allow a modern representation of failure cases - #2 by johnthagen ?

2 Likes