[lxml-dev] Renaming the drop_*() methods
Stefan Behnel
stefan_ml at behnel.de
Wed Jun 13 21:39:15 CEST 2007
Hi Ian,
Ian Bicking wrote:
> Stefan Behnel wrote:
>> as I was reviewing your code, I decided to rename drop_tag() and
>> drop_element() to drop_element() and drop_tree() respectively.
>
> I don't mind drop_tree, but I think drop_element is confusing. For
> instance, we both have different ideas about what it seems to imply --
> to me if feels like it should drop the element and its children. What
> makes it different than .remove() I guess is that it doesn't remove the
> tail
Which is a good reason why drop_element() is not a good name, you are right.
In ET, an Element is something with a tag, a text, children and a tail, and
only the tag is removed here.
So let's make it drop_tree() and drop_tag() then.
> Incidentally, someone asked for a drop_tree method in another context,
> and maybe it makes sense in more than just HTML. It's a tricky method
> to get right, in that you can do it lazily and get it wrong (e.g.,
> assume the element doesn't have a tail, or assume it does and it's not
> None, or that the element really has a previous sibling, or doesn't).
Right. But what about helper *functions* then instead? They could work on any
element, not just on those that define them as methods.
Stefan
PS: I'm setting the list back on CC to open this discussion for other comments.
More information about the lxml-dev
mailing list