]> code.delx.au - bg-scripts/blob - python24_adapter.py
wallchanger: Fixed multiple monitors on OSX again.
[bg-scripts] / python24_adapter.py
1 #! python
2
3 import collections
4
5 class defaultdict(dict):
6 def __init__(self, default_factory):
7 self.default_factory = default_factory
8 def __missing__(self, key):
9 if self.default_factory is None:
10 raise KeyError(key)
11 self[key] = value = self.default_factory()
12 return value
13 def __getitem__(self, key):
14 try:
15 return dict.__getitem__(self, key)
16 except KeyError:
17 return self.__missing__(key)
18
19 if not hasattr(collections, 'defaultdict'):
20 collections.defaultdict = defaultdict