On Tue, 19 Nov 2019 at 00:35, Soni L. <fakedme...@gmail.com> wrote: > > On 2019-11-18 5:22 p.m., Soni L. wrote: > > > > could we tweak open() so it doesn't raise immediately? this would make > > it play nicer with __enter__ but would probably break some things. > > this would make open() itself "never" fail. > > let me ask again: can we make it so open() never fails, instead > returning a file that can be either "open", "closed" or "errored"? > > operations on "errored" files would, well, raise. > > more specifically, __enter__ would raise. > > thus, `with (open("foo"), open("bar")) as (foo, bar):` would actually work.
There would have to be a very strong reason for making this kind of change to open because it would break a lot of code. Nothing in this thread comes close to warranting such a change. However there could also be a new function with a different name that behaved in a different way so that people could choose to use that if they wanted. What you are suggesting is similar to the opened function discussed elsewhere in this thread. -- Oscar _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/UJOCV2FHW2N4PEH4APKYSNO7R7TBBJNO/ Code of Conduct: http://python.org/psf/codeofconduct/