Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'will,': 0.07; 'am,': 0.13; 'wrote:': 0.15; 'billy': 0.16; 'excessively': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'op?': 0.16; 'subject:Convert': 0.16; "subject:' ": 0.16; 'have,': 0.17; 'programming': 0.18; 'received:209.85.210.174': 0.19; 'received :mail-iy0-f174.google.com': 0.19; 'header:In-Reply-To:1': 0.22; 'parse': 0.23; 'message-id:@mail.gmail.com': 0.28; '24,': 0.29; "skip:' 30": 0.29; 'skip:i 30': 0.29; 'problem': 0.29; 'sun,': 0.30; 'chris': 0.32; 'does': 0.32; 'to:addr:python-list': 0.34; "isn't": 0.35; 'issue': 0.37; 'but': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'problems': 0.38; 'solving': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.40; 'as:': 0.71; 'have.': 0.77 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=8DNVUGHo8PD3H5iW4Erw0+cCVkVo66Yio28p94iSu/M=; b=YbsgYcgK1cSxbZjAiBxGbOWEweLGyH+DSr77Lf9DitKvxlBSCxbCVEnl/cXZSZkiT8 vz6ehlijCizH0oCymzGgh4D1eo810GxPp6dY+S33AD3yj+G3v4KErXgEzwQOzAeg1kbj NQATlJjr9KSzN47XhU3dmV/M9PJufUCs8/veE= MIME-Version: 1.0 In-Reply-To: References: <4e281f97$0$16404$426a74cc@news.free.fr> <4230ed8b-5173-4408-938f-3777dcd60588@t7g2000vbv.googlegroups.com> Date: Sun, 24 Jul 2011 01:20:35 +1000 Subject: Re: Convert '165.0' to int From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1311434438 news.xs4all.nl 23837 [2001:888:2000:d::a6]:35769 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10174 On Sun, Jul 24, 2011 at 1:12 AM, Billy Mays wrote: > On 7/23/2011 3:42 AM, Chris Angelico wrote: >> >> int(s.rstrip('0').rstrip('.')) >> > > Also, it will (in?)correct parse strings such as: > > '165............00000000000000' > > to 165. Yes, it will, but is that an issue to the OP? Programming is about solving the problem you have, not the problems you don't have. Sometimes it's better to have a simple solution that does the job than an extremely complex one that isn't excessively lenient. Is it such a problem for it to be lenient? ChrisA