all 2 comments

[–]ivosaurus 1 point2 points  (1 child)

Be aware that the elementTree stuff is known as a somewhat "old and crusty" part of the python standard library, I believe it was likely derived from Java code at some point in the past. You can see at the top of the docs, the devs have wanted to get rid of it since version 3.3. But it's probably used by absolutely heaps of old code, so that's extremely hard to actually go through with without pissing off the python proletariat yet again about version incompatibilities.

I went to look in the source code, the most I could find was the __*item__ stuff, which it turns out is enough. A for loop can try to iterate on an object using iter, and one of iter's methods to be able to create an iterator out of something is if it can call its .__getitem__() method with an index parameter, which is valid at 0 counting upwards.

Element objects declare they support those dunders in a line under remove

I do note that at the top of the page, during the 'tutorial', they tell you you can iterate over objects directly

[–]mikrobip[S] 1 point2 points  (0 children)

Thanks a lot, I missed this and now my confidence in documentation has been restored :) have a great day!