Not with that part. It just looks like the code is storing things as flat local variables, that would better be organized into an object.
Seems the "depending on context" part went missing while writing my comment :)
Also, see that other comment. It just looks like code meant for translating the JSON tree into native objects, which makes the way local variables are used look a bit strange.
View all comments
Show parent comment
16
u/R3D3-1 Jul 14 '21
What we are seeing is JSON, that already is decoded into native python objects, that have a dictionary/list-like interface.
In principle it would be possible to improve this code (for a start, using a VolumeInfo class), but no possibility is QUITE that much better.
The main issue is, that the solution must handle
We also don't know if using "None" instead of "N/A" would have been reasonable for the context. It should be, but its not a certainty.
But at least the repetitive try/except structure could have been put into a function along the lines of
safegetin https://stackoverflow.com/a/25833661/2075630.Curiously, I've seen this pattern in my work environment in Fortran; People seem to be averse to writing utility functions for repetitive patterns.