[Python-ideas] collections.abc.Stream
Bar Harel
bzvi7919 at gmail.com
Sat Jun 18 07:16:51 EDT 2016
Hmm... If the term "file-like object" is so ambiguous, why does the STL use
it so much?
Perhaps a new term should be introduced clearly stating the required
methods.
On Sat, Jun 18, 2016, 2:08 PM Paul Moore <p.f.moore at gmail.com> wrote:
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160618/0f1ad67c/attachment.html>
More information about the Python-ideas
mailing list