From: Alex Martelli [mailto:aleax@aleax.it] > Indeed, why _shouldn't_ file do the obvious thing? Just > like it has a __del__ =3D close, so should it have an __exit__ > (the latter only if with IS introduced, of course). I've added a note to the PEP. The main disadvantage I can see is that if file objects have __exit__ =3D close, then people will write code which uses "with myfile". That code then won't work with a StringIO object (unless StringIO grows an __exit__ method). OK, so we add it to StringIO. But my point is that __exit__ =3D close becomes an important part of the "file-like object" protocol. I don't have a strong opinion. I've left it as an open issue. (Actually, I do have a strong opinion - I don't want to add more requirements to the already-vague file object protocol, just for the sake of convenience. But I don't want to spend time arguing over it :-)) Paul
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4