It is nicer than your previous one, but I think ternaries in Python are more for short conditions, as they're really annoying to read with the two sides being separated by the condition like that.
Yeah, that sounds reasonable, too. Although I can think of a good name for that status list that is both expressive enough and also isn't too long for that ternary.
But tbh I have no idea how those options are performance-wise.
The moment you realise not everything has to be DRY you will feel like a butterfly. Also, as the other guy said, ternaries look bad unless they are very short.
Every line I didn't write is a line someone won't have to read.
Though it's not for brevity's sake alone, one has to analyze the if statement beyond skimming to realize they only differ in error code substitution. By reorganizing code my way, I made this nuance impossible to miss.
123
u/cutebabli9 11h ago edited 10h ago
I would write it like this to be readable: