Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 38 lines (30 sloc) 0.987 kB
b2f4321 @JasonGross Minor updates. (Hopefully) finished characters.py file.
authored
1 class FrozenDict(dict):
2 """
3 A FrozenDict is an immutable dictionary.
4 """
5
6 def __init__(self, *args, **kwargs):
7 dict.__init__(self, *args, **kwargs)
8 self.__hash = None
9 self.__init__ = None
10
11 __delitem__ = None
12 __setitem__ = None
13 clear = None
14
15 def copy(self):
16 return type(self)(dict.copy(self))
17 pop = None
18 popitem = None
19 setdefault = None
20 update = None
21 def __hash__(self):
22 if self.__hash is None:
23 self.__hash = hash(tuple([(key, self[key]) for key in sorted(self.keys())]))
24 return self.__hash
25
26 def __repr__(self):
27 return '%s(%s)' % (type(self).__name__, dict.__repr__(self))
28
29 @classmethod
30 def fromkeys(S, v=None):
31 """
32 FrozenDict.fromkeys(S[,v]) -> New FrozenDict with keys from S and values equal to v.
33 v defaults to None.
34 """
35 return FrozenDict(dict.fromkeys(S, v))
36
37
Something went wrong with that request. Please try again.