def index(self, item):
"""
This is similar to index but uses id
to check for equality.
Example:
data = '<a><b></b><b></b></a>'
html = Html()
dom = html.feed(data)
for root, ind in dom.sail_with_root():
print root.name, ind.name, root.index(ind)
It would print.
a b 0
a b 1
a 0
The line where it appears ' a 0' corresponds to the
outmost object. The outmost object is an instance of Root
that contains all the other objects.
"""
count = 0
for ind in self:
if ind is item: return count
count = count + 1
raise ValueError
评论列表
文章目录