[issue42841] Add bitwise or operator to collections.abc Mapping and MutableMapping
Yurii Karabas
report at bugs.python.org
Wed Jan 6 12:49:54 EST 2021
Yurii Karabas <1998uriyyo at gmail.com> added the comment:
Thanks, for the replies, didn't know about that.
Interesting thing that `collections.abc.Set` base class has implementations of `__and__`, `__or__`, `__sub__` and `__xor__` methods, it also provide `_from_iterable` class method that is used to create `Set` instance from iterable (all of those operators use this method).
```
class Set(Collection):
...
@classmethod
def _from_iterable(cls, it):
'''Construct an instance of the class from any iterable input.
Must override this method if the class constructor signature
does not accept an iterable for an input.
'''
return cls(it)
```
Basically, my proposition was to do smth similar to `collections.abc.Mapping`, but I understand your motivation not to implement this feature.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42841>
_______________________________________
More information about the Python-bugs-list
mailing list