Author r.david.murray
Recipients benjamin.peterson, docs@python, eric.araujo, ezio.melotti, georg.brandl, hynek, ncoghlan, nikratio, pitrou, r.david.murray, rhettinger, stutzbach
Date 2014-06-17.20:28:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1403036900.88.0.316582973409.issue21763@psf.upfronthosting.co.za>
In-reply-to
Content
Well, but we think it's pretty clear.  The glossary entry says file object interfaces are defined by the classes in the io module.  As do the io module docs.  Perhaps the first sentence of the io docs could be modified to strengthen that (but it already does link to the glossary entry which is explicit that the io module defines the interfaces).

On the other hand, your statement that "few or no other assumptions are made" is, while not accurate, not *wrong*, in the following sense:  *if* a standard library module depends on file attributes and methods, then it expects them to conform to the io module interfaces.  If it does not depend on a particular part of the API, then a duck type class doesn't actually have to implement that API in order to work with that standard library module.  Of course, we might change what elements of the file API are depended on, but hopefully we only do that kind of change in a feature release.  I'm sure we have made such changes while fixing bugs, though, so if you want to be *sure* of forward compatibility, you should indeed implement the full io-specified interface in your file-like class.  Which is one reason the ABCs provide default implementations for most of the methods.  It makes it really easy to build a future-proofed duck type.
History
Date User Action Args
2014-06-17 20:28:20r.david.murraysetrecipients: + r.david.murray, georg.brandl, rhettinger, ncoghlan, pitrou, benjamin.peterson, stutzbach, ezio.melotti, eric.araujo, nikratio, docs@python, hynek
2014-06-17 20:28:20r.david.murraysetmessageid: <1403036900.88.0.316582973409.issue21763@psf.upfronthosting.co.za>
2014-06-17 20:28:20r.david.murraylinkissue21763 messages
2014-06-17 20:28:20r.david.murraycreate