On Sun, Feb 9, 2020 at 8:04 AM Random832 firstname.lastname@example.org wrote:
On Fri, Feb 7, 2020, at 13:03, Todd wrote:
approaches like opening within the dump or load, which the wiki still recommends .
So something like:
with open('myfile.p', 'wb') as f: pickle.dump(myobj, f)
What if you could write pickle.dump(myobj, with open('myfile.p', 'wb'))?
Or other similar examples such as (with open('myfile')).read() - have the compiler automatically transform the code into equivalent to wrapping the statement in a with block.
Exactly how much code would be wrapped in the 'with' block?