[lxml-dev] adding __float__, __int__ etc. to objectify.StringElement
Stefan Behnel
stefan_ml at behnel.de
Tue Apr 8 09:52:11 CEST 2008
Hi,
jholg at gmx.de wrote:
>>>> int(True)
> 1
>>>> float(True)
> 1.0
>>>> long(True)
> 1L
>>>> complex
> <type 'complex'>
>>>> complex(True)
> (1+0j)
>
> I actually wasn't aware of that behaviour of Python booleans.
> And this is definitely no priority for me. Then again, one could argue
> that BoolElement should behave as much as a native bool in Python,
> only that its XML representation is the string value "true".
Hmm, I buy that. As long as the conversion is explicit, I think objectify
Elements /should/ behave as their Python counter types.
I'll check if inheriting from IntElement does the right thing.
Stefan
More information about the lxml-dev
mailing list