Mercurial > code > home > repos > light9
view light8/util.py @ 59:001646cd5349
all mousewheel events everywhere will now pass up the tree to be caught by
all mousewheel events everywhere will now pass up the tree to be caught by
higher widgets. if things get slow, this might be the problem
author | drewp |
---|---|
date | Tue, 09 Jul 2002 07:36:29 +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