Terry J. Reedy added the comment: The intended use for str.encode is for same-type transcoding, like this:
I was unaware of the seemingly useless behavior you quote. >>> 'abc'.encode('base64') 'YWJj\n' >>> 'YWJj\n'.decode('base64') 'abc' Here is a similar use for unicode.decode. >>> u'abc'.encode('base64') 'YWJj\n' >>> u'YWJj\n'.decode('base64') 'abc' Any doc change should make the intended use clear if not already. (Note that the above give lookup errors in 3.x >>> 'abc'.encode('base64') ... LookupError: 'base64' is not a text encoding; use codecs.encode() to handle arbitrary codecs) ---------- nosy: +terry.reedy _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26369> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com