Reputation: 381
I need to check certain attributes for existence. Like:
if "blah-blah-blah" is None:
print "there is no such attribute"
else:
print "The attribute exists"
Upvotes: 14
Views: 20041
Reputation: 65851
Element
objects have all the attributes in the attrib
dict.
if 'blah' not in elem.attrib:
print "there is no such attribute"
Upvotes: 37