Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #87452

Re: Odd ValueError using float

References <me1k2i$ljt$1@ger.gmane.org> <20150314220907.GA67310@cskk.homeip.net>
Date 2015-03-15 09:20 +1100
Subject Re: Odd ValueError using float
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.378.1426371627.21433.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Mar 15, 2015 at 9:09 AM, Cameron Simpson <cs@zip.com.au> wrote:
> On 14Mar2015 08:28, Emile van Sebille <emile@fenx.com> wrote:
>>
>> It ran almost to completion before generating the error again --
>>
>> (Pdb) decval
>> '4'
>> (Pdb) type(decval)
>> <type 'str'>
>> (Pdb) len(decval)
>> 1
>> (Pdb) int(decval)
>> *** ValueError: invalid literal for int() with base 10:
>> '41.700000000000003'
>>
>> So there's still something amiss.
>
>
> Am I missing something obvious here? int() likes only ints, not floats:

Possibly missing the bit where decval looks to be a string containing
the one character U+0034 DIGIT FOUR, and then suddenly has a whole
mess of extra characters. :)

Check out the fenx stuff, as that's the only non-stdlib code you have.
Maybe it calls on a C extension module somewhere deep inside it.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Odd ValueError using float Chris Angelico <rosuav@gmail.com> - 2015-03-15 09:20 +1100

csiph-web