Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > ValueError: invalid literal for int(): 1.0000000000e+00

Reply
Thread Tools

ValueError: invalid literal for int(): 1.0000000000e+00

 
 
=?ISO-8859-2?Q?Martin_MOKREJ=A9?=
Guest
Posts: n/a
 
      02-14-2005
Hi,
is this a bug or "feature" that I have to use float() to make int() autoconvert
from it?

$ python
Python 2.3.4 (#1, Feb 14 2005, 10:00:27)
[GCC 3.3.5 (Gentoo Linux 3.3.5-r1, ssp-3.3.2-3, pie-8.7.7.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 1
>>> "%5.10e" % (a)

'1.0000000000e+00'
>>> int("%5.10e" % (a))

Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: invalid literal for int(): 1.0000000000e+00
>>> int(float("%5.10e" % (a)))

1
>>>

 
Reply With Quote
 
 
 
 
Grant Edwards
Guest
Posts: n/a
 
      02-14-2005
On 2005-02-14, Martin MOKREJŠ <(E-Mail Removed)> wrote:

> is this a bug or "feature" that I have to use float() to make int() autoconvert
> from it?


It's a feature. Integers don't have decimal points...

--
Grant Edwards grante Yow! I just had a NOSE
at JOB!!
visi.com
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Invalid Literal from MySQLdb Query Ben Last Python 0 09-28-2004 05:47 AM
Invalid Literal from MySQLdb Query Wesley Kincaid Python 0 09-27-2004 11:42 PM
What's wrong with rpc-literal? Why use doc-literal? Anonieko Ramos ASP .Net Web Services 0 09-27-2004 09:06 AM
MySQLdb returns "ValueError: invalid literal for float():" for cursor.execute('show databases') Tim Williams Python 2 05-28-2004 12:48 PM
bug in Tkinter? invalid literal for int() line 1035 Ton K. Python 3 07-07-2003 09:59 AM



Advertisments