Hi,

How can I transform b so that the assertion holds? I.e., how can I
reverse the backslash-replaced encoding, while retaining the str-type?

>>> a = u'æ'
>>> b = a.encode('ascii', 'backslashreplace')
>>> b
'\\xe6'
>>> assert isinstance(b, str) and b == 'æ'

Traceback (most recent call last):
  File "<pyshell#59>", line 1, in <module>
    assert isinstance(b, str) and b == 'æ'
AssertionError

Regards,
tores
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to