[BangPypers] help me to fix this error

Anand Balachandran Pillai abpillai at gmail.com
Tue Oct 20 12:27:54 CEST 2009


On Tue, Oct 20, 2009 at 3:38 PM, Sidharth Kuruvila <
sidharth.kuruvila at gmail.com> wrote:

> Hi,
>  Blargh! Boy! Read the mails! That code you wrote runs fine on 2.6.
> But won't run on 3.0.
>
> This should work.
>
> intab = "aeiou"
> outtab = "12345"
> trantab = str.maketrans(intab,outtab) #Watch this line!
> st = "this is string example....wow!!!";
> print(st.translate(trantab))
>
> Basically they've moved maketrans from string to str.
>

 Moral of story: Don't use functions on string module, use them on the
string
 object. Using "string.<...>" is bad coding in Python.


>
> Regards,
>  Sidharth
>
>
>


-- 
--Anand
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/bangpypers/attachments/20091020/a59e6ba7/attachment.htm>


More information about the BangPypers mailing list