You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Okay, made some progress on changing the shOpen pattern from:
sh = open(filename)
sh['data'] = data
sh.close()
to the "correct" pattern:
with open(filename) as sh:
sh['data'] = data
Early testing seems to have worked. As discussed via email, I don't think it's worth changing every instance, as several scripts in bgcval2 are not used for most purposes.
The python module shelve has some limitations:
I've also not been great at implementing it. My pattern has been:
but the preferred style uses context managers:
This is safer, clearer and more reusable.
Step 1 is to move all the shelve writes into separate functions.
Step 2 is to convert the shelve open commands into context managers.
Step 3 is to write a json version of the separate function.
Step 4 is to write a shelve to json conversion function.
Step 5: Write some tests?
The text was updated successfully, but these errors were encountered: