[Python-ideas] `to_file()` method for strings
Émanuel Barry
vgr255 at live.ca
Mon Mar 28 11:54:52 EDT 2016
I wonder how reasonable it would be to add a new keyword to open that would .close() the file object upon a single write/read. Consider:
data = open("foo.txt", "r", close_after_use=True).read()
It doesn’t rely on garbage collection to work properly, is a fancy one-liner, and is obvious that you can only read or write from/to it once. Could use a better keyword for that, though.
-Emanuel
~ If it doesn’t quack like a duck, add a quack() method ~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160328/75b3d228/attachment.html>
More information about the Python-ideas
mailing list