import xml.dom.minidom def show_bug(): document = 'foobar_attributes' dom = xml.dom.minidom.parseString(document) attribs = dom.getElementsByTagName('dom')[0].attributes if attribs.has_key('mbid'): print "This works.. found 'mbid' attribute" if 'mbid' in attribs: print "Will never get here, the above will throw an exception"