by eatonphil · 4y ago · 0 comments
The pragmatic approach I've taken to deal with this is make heavier use of custom context managers so creation and cleanup code must stay together.
But I'm also getting tired of whitespace sensitive languages.
The closest I can think of is:
if something:
...handle something..
elif something_else:
...handle something else..
if other_thing:
...handle other thing...
elif yet_another_thing:
...handle yet another thing...
else:
...for everything else...
If I had a frustration with python it would be the prevalence of "who needs types when we have dicts". This situation has been somewhat improved by dataclasses but lots of our code predates them by many years.1 - Last time I asked "who doesn't" on the internet, I found somebody who doesn't. But it's by far the most popular option.
The whitespace works differently between those languages. The Python syntax has limitations that aren't on the Haskell one.
But also, Haskell tends to place the kind of things the GP is talking about on the beginning of your expression (because of the "reverse" order on function composition), while Python tends to place them at the end of a block.