Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87450
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <cameron@cskk.homeip.net> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.019 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'permitted': 0.07; 'here?': 0.09; 'literal': 0.09; 'subject:using': 0.09; 'valueerror:': 0.09; 'python': 0.11; '"object': 0.16; '6.0': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'parts.': 0.16; 'simpson': 0.16; 'wrote:': 0.18; 'feb': 0.22; '>>>': 0.22; 'header :User-Agent:1': 0.23; 'error': 0.23; 'oriented': 0.24; 'cheers,': 0.24; 'van': 0.27; 'header:In-Reply-To:1': 0.27; 'dec': 0.30; '"",': 0.31; 'file': 0.32; 'compatible': 0.32; '(most': 0.33; 'classes': 0.35; 'something': 0.35; 'c++': 0.36; 'charset:us- ascii': 0.36; 'apple': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'generating': 0.39; 'to:addr:python.org': 0.39; 'content-disposition:inline': 0.62; 'more': 0.64; 'invalid': 0.68; 'obvious': 0.74; 'completion': 0.78; '10:': 0.84; '2014,': 0.84; '4.2.1': 0.84; 'received:192.168.15': 0.84; 'notion': 0.91 |
| Date | Sun, 15 Mar 2015 09:09:07 +1100 |
| From | Cameron Simpson <cs@zip.com.au> |
| To | python-list@python.org |
| Subject | Re: Odd ValueError using float |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii; format=flowed |
| Content-Disposition | inline |
| In-Reply-To | <me1k2i$ljt$1@ger.gmane.org> |
| User-Agent | Mutt/1.5.23 (2014-03-12) |
| References | <me1k2i$ljt$1@ger.gmane.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.19 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.377.1426370951.21433.python-list@python.org> (permalink) |
| Lines | 38 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1426370951 news.xs4all.nl 2830 [2001:888:2000:d::a6]:34542 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:87450 |
Show key headers only | View raw
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:
Python 2.7.9 (default, Dec 13 2014, 15:13:49)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> int('1.3')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1.3'
Python 3.4.3 (default, Feb 27 2015, 00:22:26)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> int('1.3')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1.3'
Cheers,
Cameron Simpson <cs@zip.com.au>
C++ also supports the notion of *friends*: cooperative classes that are
permitted to see each other's private parts.
- Grady Booch, "Object Oriented Design with Applications"
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Odd ValueError using float Cameron Simpson <cs@zip.com.au> - 2015-03-15 09:09 +1100
csiph-web