[lxml-dev] Renaming the drop_*() methods

Stefan Behnel stefan_ml at behnel.de
Thu Jun 14 07:26:25 CEST 2007


Hi Ian,

Ian Bicking wrote:
> Stefan Behnel wrote:
>>
>> Stefan Behnel wrote:
>>> Ian Bicking wrote:
>>>> 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.
>>
>> Ah, I knew I wasn't the first one who had that idea... :)
>>
>> http://effbot.org/zone/element-lib.htm
>> http://effbot.org/zone/element-bits-and-pieces.htm
>>
>> I think we should try to get back in touch with FL to see if we can't get
>> something compatible out of this. Haven't heard of him in a while,
>> though.
> 
> This was kind of what I was putting together originally in lxml.html,
> until I moved everything into the HtmlElement subclass.  Having done
> that I now prefer the methods over the functions.

Ok, I was just saying: if we want to provide the implementation in a general
fashion, a function is much better than a method. I'm not sure I want the two
methods in the _Element class for now (especially because of their tail
handling), but I think they are of general interest to users. A function in a
library would fill that need.

Stefan


More information about the lxml-dev mailing list