summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-02-06 00:15:42 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-02-06 00:15:42 (GMT)
commit0fc8351f64e11f60622de5372120f70b2fa04313 (patch)
treeb748fc7fb0c95f245f22294a4c6a912e022efaaf /Lib
parentf80680d8cdb7503c4b34e2c5a014d7c4f6e5817d (diff)
downloadcpython-0fc8351f64e11f60622de5372120f70b2fa04313.zip
cpython-0fc8351f64e11f60622de5372120f70b2fa04313.tar.gz
cpython-0fc8351f64e11f60622de5372120f70b2fa04313.tar.bz2
Remove the old UserDict module.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/UserDict.py81
1 files changed, 0 insertions, 81 deletions
diff --git a/Lib/UserDict.py b/Lib/UserDict.py
deleted file mode 100644
index cb8a826..0000000
--- a/Lib/UserDict.py
+++ /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)