Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10014
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <t@jollybox.de> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.033 |
| X-Spam-Evidence | '*H*': 0.93; '*S*': 0.00; '>>>>': 0.09; 'float': 0.13; 'wrote:': 0.15; 'concise,': 0.16; 'exception?': 0.16; 'integer.': 0.16; 'like?': 0.16; 'received:192.168.1.40': 0.16; 'subject:Convert': 0.16; "subject:' ": 0.16; 'convert': 0.19; 'this?': 0.22; 'header:In-Reply-To:1': 0.22; 'trying': 0.23; 'function': 0.26; 'raise': 0.28; 'do.': 0.30; 'shows': 0.32; 'does': 0.32; "what's": 0.33; 'to:addr:python-list': 0.34; 'header :User-Agent:1': 0.34; 'there': 0.34; 'round': 0.35; 'anything': 0.37; 'but': 0.37; 'received:192': 0.38; 'subject:: ': 0.38; 'received:192.168.1': 0.39; 'should': 0.39; 'data': 0.39; 'to:addr:python.org': 0.39; 'your': 0.60; 'received:62': 0.67; 'wish': 0.70; 'evaluate': 0.71; 'from:addr:t': 0.84 |
| Date | Thu, 21 Jul 2011 11:53:43 +0200 |
| From | Thomas Jollans <t@jollybox.de> |
| User-Agent | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110626 Iceowl/1.0b2 Icedove/3.1.11 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: Convert '165.0' to int |
| References | <j08rn1$mep$1@dough.gmane.org> |
| In-Reply-To | <j08rn1$mep$1@dough.gmane.org> |
| X-Enigmail-Version | 1.1.2 |
| OpenPGP | id=5C8691ED |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1318.1311242031.1164.python-list@python.org> (permalink) |
| Lines | 23 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1311242031 news.xs4all.nl 23884 [2001:888:2000:d::a6]:59873 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:10014 |
Show key headers only | View raw
On 21/07/11 11:31, Frank Millman wrote: > Hi all > > I want to convert '165.0' to an integer. Well, it's not an integer. What does your data look like? How do you wish to convert it to int? Do they all represent decimal numbers? If so, how do you want to round them? What if you get '165.xyz' as input? Should that raise an exception? Should it evaluate to 165? Should it use base 36? > If I convert to a float first, it does work - > >>>> int(float(x)) > 165 >>>> > > Is there a short cut, or must I do this every time (I have lots of > them!) ? I know I can write a function to do this, but is there anything > built-in? What's wrong with this? It's relatively concise, and it shows exactly what you're trying to do.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Convert '165.0' to int Thomas Jollans <t@jollybox.de> - 2011-07-21 11:53 +0200 Re: Convert '165.0' to int Frank Millman <frank@chagford.com> - 2011-07-21 04:09 -0700
csiph-web