On Thu, Jan 15, 2009 at 1:19 PM, Mr Gerard Kelly <[email protected]
> wrote:
> Thanks very much
>
> I've noticed that the eval() function gives an integer, so eval("3/2")
> gives back 1. float(eval("3/2")) doesn't seem to work, any way to get a
> floating point number back with eval()?
>
> I know you can just do ("3./2."), but is there any way to do it with
> just ("3/2")?
> _______________________________________________
> Tutor maillist - [email protected]
> http://mail.python.org/mailman/listinfo/tutor
>
Hi,
at the top of your script you can write:
from __future__ import division
now
>>> eval("4/3")
1.33333
You can read up on it here if you are interested..
http://www.python.org/dev/peps/pep-0238/
Cheers
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor