[lxml-dev] Setting URL from lxml.html.fromstring, etc

Stefan Behnel stefan_ml at behnel.de
Thu Feb 28 11:23:29 CET 2008


Hi,

Ian Bicking wrote:
> Stefan Behnel wrote:
>> I also added a "base" property to Elements that is based on the xml:base
>> attribute (or the appropriate fallback to the document URL).
> 
> Hmm... there's a property in lxml.html called .base_url, which
> previously just read docinfo.URL.  Now it could read .base... but
> obviously that's silly, as it's just an alias.
> 
> We could deprecate .base_url in lxml.html, or rename .base as .base_url,
> but having both ain't good.

I agree, wasn't aware of it. (Here, we are actually lucky that it wasn't
writable already!)

But 'base' is a better name for the XML environment given 'xml:base'. It feels
weird to set '.base_url' and have it set an xml:base attribute on the Element.
Also, it might just be a URI, although that's unlikely.

Don't you think it should behave differently for XML and HTML? For XML, I'd
expect it to depend on xml:base, while for HTML, it'd rather always depend on
the document URL (and not set an xml:base attribute on assignment).

Stefan



More information about the lxml-dev mailing list