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?
'\\xe6'>>a = u'æ'
b = a.encode('ascii', 'backslashreplace')
b
Traceback (most recent call last):>>assert isinstance(b, str) and b == 'æ'
File "<pyshell#59>", line 1, in <module>
assert isinstance(b, str) and b == 'æ'
AssertionError
Regards,
tores