#NEWLINE# def update_if( d , p , **kwds ) : #NEWLINE# #INDENT# 'Return a copy of d updated with kwds.\n\n    If no such item is in d, set item from kwds, else call p(k,v) with\n    kwds item and only set if returns True.\n\n    ' #NEWLINE# if ( p is None ) : #NEWLINE# #INDENT# p = ( lambda k , v : ( v is not None ) ) #NEWLINE# #UNINDENT# d = dict ( d ) #NEWLINE# for ( k , v ) in kwds . items ( ) : #NEWLINE# #INDENT# if ( not ( k in d ) ) : #NEWLINE# #INDENT# d [ k ] = d #NEWLINE# continue #NEWLINE# #UNINDENT# if p ( k , v ) : #NEWLINE# #INDENT# d [ k ] = v #NEWLINE# #UNINDENT# #UNINDENT# return d