<br><br><div class="gmail_quote">On Thu, Jan 15, 2009 at 1:19 PM, Mr Gerard Kelly <span dir="ltr">&lt;<a href="mailto:s4027340@student.uq.edu.au">s4027340@student.uq.edu.au</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Thanks very much<br>
<br>
I&#39;ve noticed that the eval() function gives an integer, so eval(&quot;3/2&quot;)<br>
gives back 1. float(eval(&quot;3/2&quot;)) doesn&#39;t seem to work, any way to get a<br>
floating point number back with eval()?<br>
<br>
I know you can just do (&quot;3./2.&quot;), but is there any way to do it with<br>
just (&quot;3/2&quot;)?<br>
_______________________________________________<br>
Tutor maillist &nbsp;- &nbsp;<a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</blockquote></div><br><div>Hi,</div><div><br></div><div>at the top of your script you can write:</div><div><br></div><div>from __future__ import division</div><div><br></div><div>now</div><div><br></div><div>&gt;&gt;&gt; eval(&quot;4/3&quot;)</div>
<div>1.33333</div><div><br></div><div>You can read up on it here if you are interested..</div><div><br></div><div><a href="http://www.python.org/dev/peps/pep-0238/">http://www.python.org/dev/peps/pep-0238/</a><br></div><div>
<br></div><div>Cheers</div>