<div dir="ltr"><div>I think it may be time to gently phase out "file-like" from the stdlib documentation, in favor of more precise terms like (text | binary) (input | output) stream.<br><br>There are probably a handful of cases where it's worth restricting the (duck) type more, e.g. to "an object with a readline() method returning str". But in most cases for the stdlib I favor specifying a relatively wide interface so that future evolution of the documented module is not constrained by old documentation.<br><br>For example, an API that takes a writable binary stream might currently only call .readline() on that stream, but in the future might find it more convenient to use .readlines() or .read().<br><br></div><div>As to whether we should just stick with the ABCs from 'io', there are a few problems with that, so I don't want to go there.<br><br>First, these ABCs  don't distinguish between input and output. This is intentional because otherwise there would be a bewildering set of combinations, since for each form would have to support input, output, or both -- and we already have more than enough ABCs here (IOBase, RawIOBase, BufferedIOBase, TextIOBase -- I really don't want to have to remember 12 of these).<br><br>We also need to be sensitive to the use of duck typing (which is particularly common for I/O streams) -- while it's fine to formally define an API as taking e.g. a text input stream, it's usually not fine to start asserting that it must be an instance of TextIOBase -- ABC.register() notwithstanding, that would break a lot of code. (Type annotations are a different story -- but except for brand new APIs, the stdlib should not yet start using those.)<br></div><div><br></div>PS. I assume the reference to 'STL' was meant to be 'stdlib', an innocent mistake by someone more familiar with C++, not something to be picked apart.<br clear="all"><div><div><div class="gmail_extra"><br>-- <br><div data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div></div></div>