def coerce_kw_type(kw, key, type_, flexi_bool=True):
 if ((key in kw) and (type(kw[key]) is not type_) and (kw[key] is not None)):
  if ((type_ is bool) and flexi_bool):
   kw[key] = asbool(kw[key])
  else:
   kw[key] = type_(kw[key])

def coerce_kw_type ( kw , key , type_ , flexi_bool = True ) : if ( ( key in kw ) and ( type ( kw [ key ] ) is not type_ ) and ( kw [ key ] is not None ) ) : if ( ( type_ is bool ) and flexi_bool ) : kw [ key ] = asbool ( kw [ key ] ) else : kw [ key ] = type_ ( kw [ key ] )
if key is present in dict kw .