Re: The reverse of encode('...', 'backslashreplace')

2007-09-04 Thread Duncan Booth
"Tor Erik Sønvisen" <[EMAIL PROTECTED]> wrote: > 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, st

The reverse of encode('...', 'backslashreplace')

2007-09-03 Thread Tor Erik Sønvisen
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): F