Christian Barcenas added the comment:

I'm aware of duck typing but I don't think this is the right place for it. 
(Although ABCs are ostensibly a kind of duck typing, as they do not require 
implementing classes to inherit from the ABC.)

As Martin noticed, the glossary directly defines a "mapping" as a class that 
implements the Mapping ABC, and likewise the definition of an "iterable" under 
the glossary would satisfy the Iterable ABC.

I think this is not just a documentation issue: the "quack" of a mapping has 
been well-defined and consistent since Python 2.7. Same for iterables.

(It is worth noting that 2.6's definition of mapping was indeed just any object 
with a __getitem__ method 
<https://docs.python.org/2.7/glossary.html#term-mapping>)

> I think the documentation for the dict() constructor should say how to ensure 
> the iterable and mapping modes are triggered.

Doesn't it do this already by referencing the definitions of "iterable" and 
"mapping"? These ABCs are used in other built-ins such as any() and eval().

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24659>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to