[lxml-dev] adding __float__, __int__ etc. to objectify.StringElement

jholg at gmx.de jholg at gmx.de
Wed Apr 9 08:29:04 CEST 2008


Hi,


> > 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.
> 

 Maybe the __int__, __float__ etc. methods should even go the

the ObjectifiedDataElement class? So basically every explicit to-number

conversion for data elements would work right out of the box, if the

corresponding pyval class supports it. 

For BoolElement, you'd need t override it anyway, as 
str(textOf(self._c_node))  

will not work for "true".

 Holger 


-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/lxml-dev/attachments/20080409/316d666b/attachment.htm 


More information about the lxml-dev mailing list