[Python-ideas] collections.abc.Stream
Steven D'Aprano
steve at pearwood.info
Sat Jun 18 08:16:04 EDT 2016
On Sat, Jun 18, 2016 at 11:16:51AM +0000, Bar Harel wrote:
> Hmm... If the term "file-like object" is so ambiguous, why does the STL use
> it so much?
I don't know. What is the STL and how does it relate to Python?
That's a rhetorical question. I know that the STL is C++'s Standard
Template Library, which has very little to do with Python. Their use of
the term "file-like object" is not necessarily identical to Python's use
of it.
> Perhaps a new term should be introduced clearly stating the required
> methods.
But that's the whole point -- there is no one standard set of required
methods. Some uses of a "file-like object" just require a read() or
write() method. Some might require a close() method, or a flush(),
or both. Some might need seek() and/or tell(). There's very little point
in insisting on the full interface provided by open(...) if all you need
is to call the write() method.
--
Steve
More information about the Python-ideas
mailing list