Mercurial > code > home > repos > light9
view light8/util.py @ 255:6f6d9235e8a0
TkGyro added to gyrocontroller, seems mostly functional
Some bugs that still need to be fixed:
- It refuses to go full screen on my machine.
- Text in the middle can catch some events, we'd like it to pass them to
the rectangles under it.
author | David McClosky <dmcc@bigasterisk.com> |
---|---|
date | Wed, 15 Jun 2005 20:33:05 +0000 |
parents | 71489bb71528 |
children |
line wrap: on
line source
def maxes(dicts): ''' ({'a' : 5, 'b' : 9}, {'a' : 10, 'b' : 943}) ''' newdict = {} for d in dicts: for k,v in d.items(): newdict[k] = max(v, newdict.get(k, 0)) return newdict def scaledict(d,scl): # scales all values in dict and returns a new dict return dict([(k,v*scl) for k,v in d.items()]) # class Setting that scales, maxes def subsetdict(d, dkeys, default=0): """Subset of dictionary d: only the keys in dkeys. If you plan on omitting keys, make sure you like the default.""" newd = {} # dirty variables! for k in dkeys: newd[k] = d.get(k, default) return newd