summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEeo Jun <packwolf58@gmail.com>2016-04-27 20:30:17 +0800
committerEeo Jun <packwolf58@gmail.com>2016-04-27 20:30:17 +0800
commit6747f2d84e59f1975f327eedeafd601293e3efaf (patch)
tree4113ed6732546cdaa63754bb85d61870f58963c3
parentde2d597dfe7b7551fdbd1220d1c265254ccb3266 (diff)
Even DRYer FrozenOrderedDict class
-rw-r--r--frozendict/__init__.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/frozendict/__init__.py b/frozendict/__init__.py
index 2bc90c6..289baf7 100644
--- a/frozendict/__init__.py
+++ b/frozendict/__init__.py
@@ -4,9 +4,10 @@ import functools
class frozendict(collections.Mapping):
+ dict_cls = dict
def __init__(self, *args, **kwargs):
- self._dict = dict(*args, **kwargs)
+ self._dict = self.dict_cls(*args, **kwargs)
self._hash = None
def __getitem__(self, key):
@@ -40,7 +41,4 @@ class FrozenOrderedDict(frozendict):
It is an immutable wrapper around ordered dictionaries that implements the complete :py:class:`collections.Mapping`
interface. It can be used as a drop-in replacement for dictionaries where immutability and ordering are desired.
"""
-
- def __init__(self, *args, **kwargs):
- self._dict = collections.OrderedDict(*args, **kwargs)
- self._hash = None
+ dict_cls = collections.OrderedDict