Ray.Allen <[email protected]> added the comment:
In my opinion, the set's operator should be a bit more liberal and accept any
collections.Set instances. Given collections.Set is an ABC and isinstance(set,
collections.Set) is True, the set methods should(strong recommended) follow all
the generalized abstract semantic definition in the ABC. This according to PEP
3119:
"""
In addition, the ABCs define a minimal set of methods that establish the
characteristic behavior of the type. Code that discriminates objects based on
their ABC type can trust that those methods will always be present. Each of
these methods are accompanied by an generalized abstract semantic definition
that is described in the documentation for the ABC. These standard semantic
definitions are not enforced, but are strongly recommended.
"""
The collections.Set defines __or__() as this (for example):
"""
def __or__(self, other):
if not isinstance(other, Iterable):
return NotImplemented
chain = (e for s in (self, other) for e in s)
return self._from_iterable(chain)
"""
which means the "|" operator should accept all iterable. So I think it's better
to make set's methods should be more liberal.
----------
nosy: +ysj.ray
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue8743>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com