Another (simple) unicode question

Carl Banks pavlovevidence at
Thu Oct 29 15:38:33 CET 2009

On Oct 29, 4:02 am, Rustom Mody <rustompm... at> wrote:
> Construct a kick-ass binary file
> structurer (written by a 21 year old!)
> I thought of trying to port it to python3 but it barfs on some unicode
> related stuff (after running 2to3) which I am unable to wrap my head
> around.

2to3 isn't a general Python 2 to Python 3 translator.  You can't pass
any old Python 2.x code through 2to3 and expect it to work.  Rather,
you have to write the Python 2.x code in a subset of Python that I
call "transitional dialect".  In order to port to Python 3 using 2to3,
you first have to port it to this transitional dialect.

If Unicode is the issue, one thing you should do to explicitly
classify all strings as binary or text in Python 2.x.  This means to
change str() to unicode() or bytes(), whichever is appropriate, and to
change "" to u"" or b"".

Carl Banks

More information about the Python-list mailing list