[lxml-dev] should _setElementValue add type attributes?
Stefan Behnel
stefan_ml at behnel.de
Mon Aug 27 19:36:14 CEST 2007
jholg at gmx.de wrote:
> I admit I was unsure then if this muddies the API by making
>
>>>> root = objectify.Element("root")
>>>> root.x = "3"
> behave differently from
>>>> root = objectify.fromstring("""<root><x>3</x></root>""")
>
> Kind of losing sort of a symmetry.
I can't see much of a symmetry there anyway. I'm more concerned about putting
in "3" and getting back the number 3, than putting in "<value>3</value>" and
getting back a number. The latter sounds natural to me.
>> I think that always adding a pytype will give us more predictable
>> behaviour.
>> On the other hand, we could just check if the pytype the type inference
>> mechanism returns is the type of the value, and only add the attribute if
>> that
>> is not the case. What do you think? It would not work if you exchange
>> annotated data with other machines that use different setups, but if you
>> do
>> that, you'd probably annotate everything by hand anyway.
>
> I'd rather always add the pytype, then. I just think this is simpler. And
> if you want to exchange data with other machines, better xsiannotate() to
> fall back to XML standard types, or deannotate() and rely on type inference.
Sure. So be it. :)
(... for lxml 2.0, that is)
Stefan
More information about the lxml-dev
mailing list