Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'suppress': 0.07; 'python': 0.09; 'subject:string': 0.09; 'subject:using': 0.09; 'cc:addr :python-list': 0.10; 'subject:error': 0.11; 'language': 0.14; 'cc:name:python list': 0.16; 'permissive': 0.16; 'personally,': 0.16; 'truncating': 0.16; 'string': 0.17; 'wrote:': 0.17; 'string,': 0.17; 'bit': 0.21; 'cc:2**0': 0.23; "i've": 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'values': 0.26; 'message-id:@mail.gmail.com': 0.27; 'chris': 0.28; 'fine': 0.28; '(unless': 0.29; 'behaviour': 0.29; 'complain': 0.29; 'types.': 0.29; "i'm": 0.29; 'that.': 0.30; 'usually': 0.30; 'subject: : ': 0.30; 'function': 0.30; 'error': 0.30; 'point': 0.31; 'generally': 0.32; 'getting': 0.33; 'anyone': 0.33; "can't": 0.34; 'changed': 0.34; 'received:google.com': 0.34; 'doing': 0.35; 'sometimes': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'but': 0.36; 'too': 0.36; 'being': 0.37; 'why': 0.37; 'received:209': 0.37; 'well.': 0.37; 'subject:: ': 0.38; 'where': 0.40; 'stuck': 0.65; '2013': 0.84; 'front.': 0.84; 'oscar': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=TKBgxdYHUau5kbkn1PyecF6i2BPvM7O1ucaBnQeKLjs=; b=ma2ZZfbE+pZn6w6Fz+Muz5yqI7BkiRbCrQwHq6cQIvUFZOnYx0/PLPV2sJZ5npUqjH WxZHzHbxigy8Da+swObwcXAAieR5QzLwxPWMvlinjResyfmWe2P4ygOHVgM39d5Be2B5 j1sPjoZqK4H3jLkAarcb+qCz/FfYrAb9i9Xq+9Y4H/+lukOO/iEavy7Dut1S5+egNPJA aHXdJHg1LeeUNjBFmNnX2y2EuaZQjXftloFUJpBkrMFV9GC1Huja00v/KC/jLkpubHrS kxjxrQ8IbH2SVlHN9kRDjDdNSCbqxiwvnaa1JQ4K7YnZPKjUmGo6TIKKU3BEAOi7jKWl 7kbg== MIME-Version: 1.0 X-Received: by 10.152.111.102 with SMTP id ih6mr3552028lab.20.1359075802095; Thu, 24 Jan 2013 17:03:22 -0800 (PST) In-Reply-To: References: <51011822.3020702@tobix.eu> Date: Fri, 25 Jan 2013 01:03:21 +0000 Subject: Re: using split for a string : error From: Oscar Benjamin To: Chris Angelico Content-Type: text/plain; charset=ISO-8859-1 Cc: Python List X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1359075803 news.xs4all.nl 6861 [2001:888:2000:d::a6]:42835 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37643 On 24 January 2013 11:35, Chris Angelico wrote: > > It's usually fine to have int() complain about any non-numerics in the > string, but I must confess, I do sometimes yearn for atoi() semantics: > atoi("123asd") == 123, and atoi("qqq") == 0. I've not seen a > convenient Python function for doing that. Usually it involves > manually getting the digits off the front. All I want is to suppress > the error on finding a non-digit. Oh well. > I'm interested to know what the situations are where you want the behaviour of atoi(). Personally, I consider the int() function too permissive because of its behaviour in truncating non-integer numeric types. But then that's because I'm always paranoid that the values of my precious numbers are being changed without my knowledge. From my vantage point I really can't see why the ambiguous behaviour of atoi() would actually be desired by anyone (unless they were stuck using a language that made string manipulation generally a bit awkward). Oscar