Message149436
| Author |
petri.lehtinen |
| Recipients |
cool-RR, ezio.melotti, petri.lehtinen |
| Date |
2011年12月14日.09:30:35 |
| SpamBayes Score |
1.5101531e-11 |
| Marked as misclassified |
No |
| Message-id |
<1323855036.52.0.167594584134.issue13600@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Ram Rachum wrote:
> The `rot_13` codec is supposed to work like this, no?
No it isn't. In Python 3, str.encode() always encodes to bytes and bytes.decode() always decodes to str. IOW, str.encode() encodes text (Unicode) to data (bytes), and bytes.decode() decodes data to text. ROT-13 is not a character encoding, so it cannot be used in this manner.
It's still available in the codecs module, though:
>>> import codecs
>>> codecs.lookup('rot-13').encode('qwerty')
('djregl', 6)
Other text->text and bytes->bytes codecs are also available there. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年12月14日 09:30:36 | petri.lehtinen | set | recipients:
+ petri.lehtinen, ezio.melotti, cool-RR |
| 2011年12月14日 09:30:36 | petri.lehtinen | set | messageid: <1323855036.52.0.167594584134.issue13600@psf.upfronthosting.co.za> |
| 2011年12月14日 09:30:35 | petri.lehtinen | link | issue13600 messages |
| 2011年12月14日 09:30:35 | petri.lehtinen | create |
|