>>> eval("float(3/2)")
>>
>> That still does not work, because the 'float' comes after the
>> division. 3/2 equals 1, so float(3/2) equals 1.0. To make it work,
>> you'll have to put the float inside the division:
>> eval("float(3)/2")
correct. as long as one of the operands is a float, the divisi
"Andre Engels" wrote
eval("float(3/2)")
That still does not work, because the 'float' comes after the
division. 3/2 equals 1, so float(3/2) equals 1.0. To make it work,
you'll have to put the float inside the division:
eval("float(3)/2")
Ahem! Quite. That was what I actually intended to p
On Thu, Jan 15, 2009 at 1:08 PM, Alan Gauld wrote:
>
> "Mr Gerard Kelly" wrote
>
>> 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()?
>
> Move the float insid
"Mr Gerard Kelly" wrote
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()?
Move the float inside the eval:
eval("float(3/2)")
It's nothing to do with eval b
On Thu, Jan 15, 2009 at 9:42 AM, Bill Campbell wrote:
> Python does the Right Thing(tm) when dividing two integers,
> returning an integer result.
>
Unless it is python 3k, in which integer division (single /) can
result in float. Because int is a long by default. :-)
--
Senthil
__
On Wed, Jan 14, 2009, jadrifter wrote:
>On Thu, 2009-01-15 at 12:19 +1000, Mr Gerard Kelly 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 bac
On Thu, 2009-01-15 at 12:19 +1000, Mr Gerard Kelly 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 ("
Mr Gerard Kelly 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
jus
On Thu, Jan 15, 2009 at 1:19 PM, Mr Gerard Kelly 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.
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")?
__
10 matches
Mail list logo