]> granicus.if.org Git - python/commitdiff
Remove the old UserDict module.
authorRaymond Hettinger <python@rcn.com>
Wed, 6 Feb 2008 00:15:42 +0000 (00:15 +0000)
committerRaymond Hettinger <python@rcn.com>
Wed, 6 Feb 2008 00:15:42 +0000 (00:15 +0000)
Lib/UserDict.py [deleted file]
Misc/NEWS

diff --git a/Lib/UserDict.py b/Lib/UserDict.py
deleted file mode 100644 (file)
index cb8a826..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-"""A more or less complete user-defined wrapper around dictionary objects."""
-
-class UserDict:
-    def __init__(self, dict=None, **kwargs):
-        self.data = {}
-        if dict is not None:
-            self.update(dict)
-        if len(kwargs):
-            self.update(kwargs)
-    def __repr__(self): return repr(self.data)
-    def __eq__(self, dict):
-        if isinstance(dict, UserDict):
-            return self.data == dict.data
-        else:
-            return self.data == dict
-    def __ne__(self, dict):
-        if isinstance(dict, UserDict):
-            return self.data != dict.data
-        else:
-            return self.data != dict
-    def __len__(self): return len(self.data)
-    def __getitem__(self, key):
-        if key in self.data:
-            return self.data[key]
-        if hasattr(self.__class__, "__missing__"):
-            return self.__class__.__missing__(self, key)
-        raise KeyError(key)
-    def __setitem__(self, key, item): self.data[key] = item
-    def __delitem__(self, key): del self.data[key]
-    def clear(self): self.data.clear()
-    def copy(self):
-        if self.__class__ is UserDict:
-            return UserDict(self.data.copy())
-        import copy
-        data = self.data
-        try:
-            self.data = {}
-            c = copy.copy(self)
-        finally:
-            self.data = data
-        c.update(self)
-        return c
-    def keys(self): return self.data.keys()
-    def items(self): return self.data.items()
-    def values(self): return self.data.values()
-    def update(self, dict=None, **kwargs):
-        if dict is None:
-            pass
-        elif isinstance(dict, UserDict):
-            self.data.update(dict.data)
-        elif isinstance(dict, type({})) or not hasattr(dict, 'items'):
-            self.data.update(dict)
-        else:
-            for k, v in dict.items():
-                self[k] = v
-        if len(kwargs):
-            self.data.update(kwargs)
-    def get(self, key, failobj=None):
-        if key not in self:
-            return failobj
-        return self[key]
-    def setdefault(self, key, failobj=None):
-        if key not in self:
-            self[key] = failobj
-        return self[key]
-    def pop(self, key, *args):
-        return self.data.pop(key, *args)
-    def popitem(self):
-        return self.data.popitem()
-    def __contains__(self, key):
-        return key in self.data
-    @classmethod
-    def fromkeys(cls, iterable, value=None):
-        d = cls()
-        for key in iterable:
-            d[key] = value
-        return d
-
-class IterableUserDict(UserDict):
-    def __iter__(self):
-        return iter(self.data)
index 5e90be4a3dc49f4bd888851a5cdf9404327539c6..50eb9c09db00074b1065e90d3adc7fb044fe857c 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -75,7 +75,7 @@ Library
 
 - Created new UserDict class in collections module.  This one inherits from and
   complies with the MutableMapping ABC.  
-  XXX still need to covert old UserDict based tests and eliminate the old UserDict module.
+  XXX still need to move docs
 
 - Removed UserDict.DictMixin.  Replaced all its uses with collections.MutableMapping.