[Python-ideas] collections.abc.Stream

Bar Harel bzvi7919 at gmail.com
Sat Jun 18 07:47:12 EDT 2016


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

But then again, the problem is that you don't know what methods are needed
by the code. Even if you don't type-check, an ABC gives you a general idea
of the methods needed for the code to work whether you inherit from it, or
just look at it.
I believe trial & error, and looking through the source code is a poor
solution compared to the precise documentation of the required methods.

On Sat, Jun 18, 2016 at 2:27 PM Paul Moore <p.f.moore at gmail.com> wrote:

> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160618/2ceb7085/attachment.html>


More information about the Python-ideas mailing list