<br><br><div class="gmail_quote">On Tue, Oct 20, 2009 at 3:11 PM, Senthil Kumar M <span dir="ltr">&lt;<a href="mailto:msenthil008@gmail.com">msenthil008@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><div>from string import maketrans</div><div>intab = &quot;aeiou&quot;</div><div>outtab = &quot;12345&quot;</div></div><div>trantab = maketrans(intab,outtab)</div><div>st = &quot;this is string example....wow!!!&quot;;</div>
<div>
print(st.translate(trantab))</div><div>------------------------------------------------------</div><div><br></div><div>I got this error,</div><div><br></div><div><div>Traceback (most recent call last):</div><div>  File &quot;C:\Python30\fullpath.py&quot;, line 4, in &lt;module&gt;</div>

<div>    trantab = maketrans(intab,outtab)</div><div>  File &quot;C:\Python30\lib\string.py&quot;, line 55, in maketrans</div><div>    raise TypeError(&quot;maketrans arguments must be bytes objects&quot;)</div><div>TypeError: maketrans arguments must be bytes objects</div>
</div></blockquote><div><br>Spend some time learning Python and use this list only for help on<br>things which you can&#39;t figure out even after trying. Don&#39;t use the list<br>as a help() on paste every other Python exception thrown by the interpreter,<br>
expecting someone to spoon feed your Python trip.<br><br>In this case, check out the Python documentation on string module.<br><br><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div><br></div><div><br></div><div><br></div></div><div><div></div><div class="h5"><br><div class="gmail_quote">On Tue, Oct 20, 2009 at 2:59 PM, Anand Balachandran Pillai <span dir="ltr">&lt;<a href="mailto:abpillai@gmail.com" target="_blank">abpillai@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><br><div class="gmail_quote"><div>On Tue, Oct 20, 2009 at 2:40 PM, Senthil Kumar M <span dir="ltr">&lt;<a href="mailto:msenthil008@gmail.com" target="_blank">msenthil008@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>----------------------------------------------------------</div><div>#!/usr/bin/python</div><div><br></div><div>from string import maketrans   </div><div>intab = &quot;aeiou&quot;</div><div>outtab = &quot;12345&quot;</div>



<div>trantab = intab.maketrans(outtab)</div><div><br></div><div>str = &quot;this is string example....wow!!!&quot;;</div><div>print str.translate(trantab);</div></blockquote></div><div><br> &quot;print&quot; is a function from python 3.0. Change this to,<br>


 print (str.translate(trantab))<br><br> And you don&#39;t need semi-colons in Python. Semi-colons<br> are used only to separate 2 expressions in the same line.<br> Something like<br><br> x=2; print x<br><br> Here they are superfluous. <br>


 <br> And I think &quot;outtab&quot; should be a dict, not string... but I am not sure.<br><br></div><div><div></div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


<div><br></div><div>------------------------------------------------------------</div>
<div>Thanks for the response.</div><div>I changed the code as above</div><div>this code too shows an error. </div><div><div></div><div><div><br></div><br><div class="gmail_quote">On Tue, Oct 20, 2009 at 2:23 PM, Sidharth Kuruvila <span dir="ltr">&lt;<a href="mailto:sidharth.kuruvila@gmail.com" target="_blank">sidharth.kuruvila@gmail.com</a>&gt;</span> wrote:<br>



<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
This looks like it&#39;s because python&#39;s strings have change in python 3.<br>
The characters used to be 8bit bytes but now they are 16 bits wide.<br>
<br>
A quick google tells me that str now has a method called maketrans so<br>
s1.maketrans(s2) should work.<br>
<br>
I&#39;m guessing you are using a tutorial written for one of the older<br>
versions of python. I&#39;d suggest you either find a python 3 based<br>
tutorial or use an older version of python, maybe python 2.6.<br>
<br>
ps Can you cut and paste the code into the mail next time, images are<br>
a pain to work with.<br>
<br>
Regards,<br>
Sidharth<br>
<div><div></div><div><br>
On Tue, Oct 20, 2009 at 1:52 PM, Senthil Kumar M &lt;<a href="mailto:msenthil008@gmail.com" target="_blank">msenthil008@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; I am using python IDLE (python3.0.1) . I dont know why this error comes ? I<br>
&gt; am a new user to python.<br>
&gt;<br>
&gt; the link of the image snapshot is<br>
&gt; <a href="http://img197.imageshack.us/img197/3405/pythonshell.png" target="_blank">http://img197.imageshack.us/img197/3405/pythonshell.png</a><br>
&gt;<br>
&gt; --<br>
&gt; ********************<br>
&gt; M.Senthil Kumar<br>
&gt; ********************<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; BangPypers mailing list<br>
&gt; <a href="mailto:BangPypers@python.org" target="_blank">BangPypers@python.org</a><br>
&gt; <a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
&gt;<br>
&gt;<br>
<font color="#888888"><br>
<br>
<br>
--<br>
I am but a man.<br>
_______________________________________________<br>
BangPypers mailing list<br>
<a href="mailto:BangPypers@python.org" target="_blank">BangPypers@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
</font></blockquote></div><br><br clear="all"><br></div></div><font color="#888888">-- <br>********************<br>M.Senthil Kumar<br>********************<br>
</font><br>_______________________________________________<br>
BangPypers mailing list<br>
<a href="mailto:BangPypers@python.org" target="_blank">BangPypers@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
<br></blockquote></div></div></div><br><br clear="all"><br>-- <br><font color="#888888">--Anand<br><br><br><br>
</font><br>_______________________________________________<br>
BangPypers mailing list<br>
<a href="mailto:BangPypers@python.org" target="_blank">BangPypers@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>********************<br>M.Senthil Kumar<br>********************<br>
</div></div><br>_______________________________________________<br>
BangPypers mailing list<br>
<a href="mailto:BangPypers@python.org">BangPypers@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>--Anand<br><br><br><br>