Thank you, eryksun. using tounicode seems to work on this small piece of code. It still has issues with my code which is generating a big XML code. I will figure out why. -SM
On Thu, Nov 28, 2013 at 2:45 PM, eryksun <eryk...@gmail.com> wrote: > On Thu, Nov 28, 2013 at 2:12 PM, SM <sunith...@gmail.com> wrote: > > Run with Python3: > > > > $ python3 testx.py > > b'<root>\n <child/>\n <child>some text</child>\n</root>\n' > > print() first gets the object as a string. tostring() returns bytes, > and bytes.__str__ returns the same as bytes.__repr__. You can decode > the bytes before printing, or instead use tounicode(): > > >>> s = etree.tounicode(root, pretty_print=True) > >>> print(s) > <root> > <child/> > <child>some text</child> > </root> >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor