Skip to content

Instantly share code, notes, and snippets.

@tomthepythonist
Created January 21, 2010 18:53
Show Gist options
  • Save tomthepythonist/283064 to your computer and use it in GitHub Desktop.
Save tomthepythonist/283064 to your computer and use it in GitHub Desktop.
# Method 0
attribs = {}
for elem in config_etree:
try:
attribs[elem.tag] = elem.text
except:
ET.dump(elem) #prints the xml to stdout so I can see why it failed
curr_tileset.__dict__.update(attribs)
# Method 1
attribs = {}
for elem in config_etree:
if hasattr(elem, "text"):
attribs[elem.tag] = elem.text
else:
ET.dump(elem)
curr_tileset.__dict__.update(attribs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment