def itemmap(func, d, factory=dict):
 rv = factory()
 rv.update(map(func, iteritems(d)))
 return rv

def itemmap ( func , d , factory = dict ) : rv = factory ( ) rv . update ( map ( func , iteritems ( d ) ) ) return rv
apply function to items of dictionary .