Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check attribute existings by Elementtree?

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"
like image 252
user1464922 Avatar asked Jun 21 '12 15:06

user1464922


1 Answers

Element objects have all the attributes in the attrib dict.

if 'blah' not in elem.attrib:
   print "there is no such attribute"
like image 70
Lev Levitsky Avatar answered Nov 05 '22 12:11

Lev Levitsky