summaryrefslogtreecommitdiffstats
path: root/Lib/collections
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/collections')
-rw-r--r--Lib/collections/__init__.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index 178cdb1..1aa7d10 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -994,6 +994,26 @@ class UserDict(_collections_abc.MutableMapping):
# Now, add the methods in dicts but not in MutableMapping
def __repr__(self): return repr(self.data)
+
+ def __or__(self, other):
+ if isinstance(other, UserDict):
+ return self.__class__(self.data | other.data)
+ if isinstance(other, dict):
+ return self.__class__(self.data | other)
+ return NotImplemented
+ def __ror__(self, other):
+ if isinstance(other, UserDict):
+ return self.__class__(other.data | self.data)
+ if isinstance(other, dict):
+ return self.__class__(other | self.data)
+ return NotImplemented
+ def __ior__(self, other):
+ if isinstance(other, UserDict):
+ self.data |= other.data
+ else:
+ self.data |= other
+ return self
+
def __copy__(self):
inst = self.__class__.__new__(self.__class__)
inst.__dict__.update(self.__dict__)