[Python-ideas] collections.abc.Stream
Paul Moore
p.f.moore at gmail.com
Sat Jun 18 07:08:57 EDT 2016
On 17 June 2016 at 23:21, Bar Harel <bzvi7919 at gmail.com> wrote:
> +1 although isn't io.IOBase already an ABC for file-like objects?
To an extent, but it would likely be an error to typecheck for it.
There's a huge history of people implementing objects with (for
example) just a read() method and expecting it to work in functions
that need files but only actually use that one method. The idea of a
"file-like object" predates ABCs by such a long time that code that
defines "file-like" via any ABC will be seen as "broken" by someone
(for public libraries at least - for private code you can of course
follow whatever conventions you want).
> Perhaps there should be some kind of reference to it in collections.abc? Maybe an alias even?
I would think that would be a mistake. Far too often it wouldn't do
what people would expect, so it'd end up being more of a hindrance
than a help.
Paul
More information about the Python-ideas
mailing list