On Fri, Aug 06, 2021 at 09:30:57AM +0100, Sam Frances wrote:
All good points. To me there is an elegance in being able to split the different paths of the function into their own syntactically separate function definitions.
Do you use `functools.singledispatch`? Thatt gets you part-way there.
One place where this excels is in handling happy paths vs error paths. It increases clarity substantially, in my experience, to be able to code the happy path without separately from the error path.
I don't know... it seems to me that the error path is generally going to be a single statement, `raise SomeException(message)`. Does that really need to be its own function?
It might help if you show some real code rather than trivial examples like recursive fibonacci and made-up toy functions.