durusmail: qp: What should repr() of an h8 instance give?
What should repr() of an h8 instance give?
2008-01-23
2008-02-04
What should repr() of an h8 instance give?
mario ruggier
2008-01-23
Hello!

i stumbled on this when trying to stock away an h8 instance for later
use, specifically via repr() and then eval(). However doing a repr() of
an h8 instance gives the same as a repr() of a unicode instance. The
following interactive session maybe shows this more clearly:

$ python
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> from qpy import h8
 >>> x = h8('some xml string')
 >>> x
u'some xml string'
 >>> repr(x)
"u'some xml string'"
 >>> y = eval(repr(x))
 >>> y
u'some xml string'
 >>> y == x
True
 >>> y.__class__, x.__class__
(, )
 >>>

What should repr() of an h8 instance give?

mario

reply