# Returns deep copy of body in XML, using passed in name
def find_body_by_name(xml_root, target_name=None):
if target_name is not None:
for body in xml_root.findall(".//body"):
if body.attrib.get("name") == target_name:
return copy.deepcopy(body)
worldbody = xml_root.find(".//worldbody")
if worldbody is not None and len(worldbody) > 0:
for body in worldbody.findall("body"):
return copy.deepcopy(body)
return None
Hey guys, I had a question about this, specifically the following part:
for body in worldbody.findall("body"):
return copy.deepcopy(body)
why are you returning just the first element and not all of them?
Hey guys, I had a question about this, specifically the following part:
why are you returning just the first element and not all of them?