[Python-ideas] collections.abc.Stream

Paul Moore p.f.moore at gmail.com
Sat Jun 18 07:27:05 EDT 2016


On 18 June 2016 at 12:16, Bar Harel <bzvi7919 at gmail.com> wrote:
> Hmm... If the term "file-like object" is so ambiguous, why does the STL use
> it so much?

Not sure what you mean by the STL? Do you mean the standard library?
Because it was an easily-understandable term to use, even though it
does require context (and sometimes a little bit of trial and error,
or reading the source) to understand the precise requirements.
Historically, the stdlib docs were somewhat more informal in their
language than people seem to expect these days. (Personally, I think a
bit of informality is fine, but opinions differ).

> Perhaps a new term should be introduced clearly stating the required
> methods.

The point is there would be many separate terms, each stating
different sets of methods. Or people would be required to implement
unnecessary methods just to satisfy the constraints of an
overly-strict type check.

This is the fundamental idea behind duck typing - you only need to
implement the methods needed by the code you're calling.
Paul


More information about the Python-ideas mailing list