I’ve often wanted this for other things that share a similar API, JSON comes to mind.
Loading from/saving to a file is a pretty common thing— nice to make it easy.
And JSON at least has *s versions for strings, so no confusion there.
But it’s been this way a LONG time, and with a general trend of Python becoming more of a systems that scripting language, I don’t see it changing.
PS: you don’t need the context manager — at least in cPython — you can put the open call right in the call to load()--
Christopher Barker, PhD
Python Language Consulting
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython