[lxml-dev] 2.1beta questions: objectify.XML, objectify.parse base_url arg, deprecate enableRecursiveStr, etree.tounicode()

Stefan Behnel stefan_ml at behnel.de
Tue Jul 1 19:13:04 CEST 2008


Hi Holger,

jholg at gmx.de wrote:
> I started having a bad conscience for never really looking at 
> 2.1 for quite a while.
> 
> Works smoothly for me for all I can tell. 

Glad to hear that.


>>> I guess the module functions XML() and parse() should also support the
>>> base_url arg?
> 
> Implemented on trunk, revision  56201.
> I stole the unittests from test_etree and noticed that I also had to 
> special case 'base' in objectify's __setattr__ magic.

Thanks!


>>> Also, I suppose enableRecursiveStr() could be removed?
>> I never really liked it, but why would you want to remove it?
> 
> some other of the old CamelCase method/function names went away, so I 
> figured this can also go.

Yep, please do so.


>>> I suppose this is owed to ElementTree API compat which doesn't have
>>> tounicode() - or is this a py3k issue?
>> Actually, the "encoding=unicode" bit has a Py3k issue. In Py3, you have 
>> to say "encoding=str" instead...
> 
> How do you specify which actual encoding, e.g 'ISO-8859-15', here?

Same as before. You get a byte string when you pass an encoding name, and a
unicode string (str type) when you pass str. That's also something I like
about the new interface.


> Yet another parameter to tostring() feels awkward, and renaming the 
> parameter conflicts with ElementTree compatibility.

It would also require a bit more parameter checking and exception raising. The
unicode option and the encoding are mutually exclusive, and unicode is not so
far from an encoding that it would really merit an option on its own.

Note also that you do not pass "Unicode" as a string but the unicode type, and
you get a unicode object back.

Stefan



More information about the lxml-dev mailing list