[Python-Dev] Adding .decode() method to Unicode
Barry A. Warsaw
barry@digicool.com
Tue, 12 Jun 2001 14:35:10 -0400
>>>>> "MvL" == Martin v Loewis <martin@loewis.home.cs.tu-berlin.de> writes:
MvL> What is the type of parts[3] here? If it is a plain string,
MvL> it is already possible:
>> 'SGVsbG8=\n'.decode("base64")
MvL> 'Hello'
But only in Python 2.2a0 currently, right? And yes, the type is plain
string.
MvL> I doubt you'd ever have a Unicode string that represents a
MvL> base64-encoded byte string, and if you had, .decode would
MvL> probably do the wrong thing:
>> import codecs enc,dec,_,_ = codecs.lookup("base64")
>> dec(u'SGVsbG8=\n')
MvL> ('Hello', 9)
MvL> Note that this returns a byte string, not a Unicode string.
I trust you on that. ;) I've only played with this tangentially since
this thread cropped up.
-Barry