How can I ignore ValueError when I try to remove an element from a list?
A good and thread-safe way to do this is to just try it and ignore the exception: try: a.remove(10) except ValueError: pass # do nothing!
A good and thread-safe way to do this is to just try it and ignore the exception: try: a.remove(10) except ValueError: pass # do nothing!
Sounds like you’re overthinking it. You’ve observed the difference between childNodes and children, which is that childNodes contains all nodes, including text nodes consisting entirely of whitespace, while children is a collection of just the child nodes that are elements. That’s really all there is to it. There is nothing unpredictable about either collection, although … Read more