68 """Replace one object with a different one of the same type. 70 This function replaces the contents of `fromObj` object with those of `toObj`, 71 so all references ot it remain valid. 74 if not isinstance(toObj, type(fromObj)):
75 raise TypeError(
'replaceWith requires both arguments to be the same type')
77 if isinstance(toObj, cms._ModuleSequenceType):
78 fromObj._seq = toObj._seq
80 elif isinstance(toObj, cms._Parameterizable):
82 for p
in fromObj.parameterNames_():
84 for p
in toObj.parameterNames_():
85 setattr(fromObj, p, getattr(toObj, p))
86 if isinstance(toObj, cms._TypedParameterizable):
87 fromObj._TypedParameterizable__type = toObj._TypedParameterizable__type
90 raise TypeError(
'replaceWith does not work with "%s" objects' %
str(type(fromObj)))
def replace_with(fromObj, toObj)