def replace_node(ptr, value):
 (parent, attrname, listidx) = ptr
 if (listidx is None):
  setattr(parent, attrname, value)
 else:
  getattr(parent, attrname)[listidx] = value

def replace_node ( ptr , value ) : ( parent , attrname , listidx ) = ptr if ( listidx is None ) : setattr ( parent , attrname , value ) else : getattr ( parent , attrname ) [ listidx ] = value
replaces a node .