On Friday, March 2, 2018 at 12:22:13 AM UTC, MRAB wrote: > On 2018-03-01 23:38, ooomzay wrote: [Snip] > > PEP343 requires two new methods: __enter__ & __exit__. > > RIAA requires no new methods. > > > > RIAA resources are invariant: If you have a reference to it you can use it. > > PEP343 resources can not be invariant: To be robust the enter/exit state > > must be tracked and checked. (assert self.handle in the example) [Snip] > > PEP343 requires specialised "with" syntax, RIAA requires no new syntax. > > Furthermore, although src & dst objects are still accessible outside the > > PEP343 "with" block they are not in a usable state (not invariant). > > > > In the RIAA case the resources are guaranteed to be in a usable state as > > long > > as any reference exists (invariant). References can also be safely > > passed around.The resource will be freed/closed when the last man has > > finished > > with it, even in the face of exceptions. > > [snip] > > > What's the difference between 'RAIIFileAccess' and 'open'?
I listed all the differences I know of in my preceding post. (I have snipped the other stuff so they are easy to see). -- https://mail.python.org/mailman/listinfo/python-list