[BangPypers] 2to3 fixers

Senthil Kumaran orsenthil at gmail.com
Sat Jun 12 01:46:55 CEST 2010


On Sat, Jun 12, 2010 at 12:55:25AM +0530, Zubin Mithra wrote:
> I just discovered that the following construct does not work in Py3k.
> 
> >>> string.maketrans('-', '_')
> 
> 
> When i try to convert a python module containing the above construct,
> it does not get modified in a way such that it could run on Python 3.0

That is because, string is unicode in py3k and maketrans is for former
8bit string. Actually, its got to do with semantics, that is why 2to3
can't help you here.

BTW, you might this example helpful for your understanding.

http://uthcode.sarovar.org/pycon2010/strings.html#string-translate-method-and-maketrans-function

> 2. write a fixer for doing this which I could use. I could`nt find any
> good tutorials out there on writing fixers, i`d be grateful if you
> could point me to any.

2to3 is a context free source to source translation tool. It is very
comprehensive. It requires a good skills in Compilers if you were to
write something more than that.


-- 
Senthil



More information about the BangPypers mailing list