how to insert random error in a programming

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon Oct 15 23:46:48 EDT 2012


On Mon, 15 Oct 2012 18:21:55 -0700, alex23 wrote:

> On Oct 16, 5:52 am, Chris Angelico <ros... at gmail.com> wrote:
>> Surely there's a shorter way to rot13 a piece of text? CODE GOLF!
> 
> In Python2: "a piece of string".encode('rot13') :)

And in Python 3, unfortunately there has been a right-royal mess made of 
the codecs system:

http://bugs.python.org/issue7475

So I expect that in Python 3.4 this will work:

"a piece of string".transform('rot13')

or this:

import codecs
codecs.encode('a piece of string', 'rot13')


but who knows really?



-- 
Steven



More information about the Python-list mailing list