#NEWLINE# def _rapply( d , func , * args , **kwargs ) : #NEWLINE# #INDENT# 'Apply a function to all values in a dictionary or list of dictionaries, recursively.' #NEWLINE# if isinstance ( d , ( tuple , list ) ) : #NEWLINE# #INDENT# return [ _rapply ( each , func , * args , ** kwargs ) for each in d ] #NEWLINE# #UNINDENT# if isinstance ( d , dict ) : #NEWLINE# #INDENT# return { key : _rapply ( value , func , * args , ** kwargs ) for ( key , value ) in iteritems ( d ) } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return func ( d , * args , ** kwargs )