durusmail: qp: QPY h8 and unicode.replace
QPY h8 and unicode.replace
2008-05-02
David K. Hess
2008-05-02
Binger David
2008-05-04
Mario Ruggier
2008-05-04
Binger David
2008-05-05
David K. Hess
2008-05-06
Mario Ruggier
QPY h8 and unicode.replace
David K. Hess
I've run into the following behavior with qpy:

 >>> h8("%s") % h8("<hello>")
u'<hello>'
 >>> h8("%s") % h8.quote("<hello>")
u'&lt;hello&gt;'
 >>> h8("%s") % h8.quote("<hello>").replace("h", "a")
u'&amp;lt;aello&amp;gt;'
 >>> h8("%s") % h8(h8.quote("<hello>").replace(h8("h"), h8("a")))
u'&lt;aello&gt;'
 >>>

What I'm running into appears to be that h8.replace returns a unicode
instance instead of an h8 instance.

Would it be more appropriate if all of the h8 inherited methods
returned h8 instances instead? Or am I missing something....

Dave



reply