Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eweka.nl!lightspeed.eweka.nl!194.134.4.91.MISMATCH!news2.euro.net!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'exception': 0.03; 'received:209.85.223': 0.03; 'messages.': 0.04; 'case.': 0.05; 'python': 0.09; '(it': 0.09; 'abort': 0.09; 'imply': 0.09; 'literal': 0.09; 'subject:string': 0.09; 'subject:using': 0.09; 'valueerror': 0.09; 'cc:addr:python-list': 0.10; 'programmer': 0.11; 'subject:error': 0.11; 'ignore': 0.13; '24,': 0.16; 'correctness.': 0.16; 'integers,': 0.16; 'landing': 0.16; 'supress': 0.16; 'sure.': 0.16; 'wrote:': 0.17; 'script.': 0.17; 'skip': 0.17; 'thu,': 0.17; 'jan': 0.18; '>>>': 0.18; 'trying': 0.21; "i'd": 0.22; 'cc:2**0': 0.23; "python's": 0.23; 'raise': 0.24; 'specifically': 0.24; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; '(which': 0.26; 'checking': 0.27; 'first,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'chris': 0.28; '>>>>': 0.29; 'url:mailman': 0.29; 'skip:& 10': 0.29; "i'm": 0.29; 'maybe': 0.29; 'subject: : ': 0.30; 'error': 0.30; 'url:python': 0.32; 'print': 0.32; 'url:listinfo': 0.32; 'another': 0.33; 'agree': 0.34; 'received:google.com': 0.34; 'thanks': 0.34; 'ahead': 0.35; 'pm,': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'url:org': 0.36; "didn't": 0.36; 'should': 0.36; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'where': 0.40; 'help': 0.40; 'url:mail': 0.40; 'think': 0.40; 'worth': 0.63; 'more': 0.63; 'cast': 0.65; 'friendly': 0.71; 'absolutely': 0.84; '2013': 0.84; 'say:': 0.84; 'warning.': 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=GW2ywi9FuddrYSmkbeWgklC80tHb8x/CICOLYGuRi4c=; b=dqBHHS10M9PrZZCu7RJZwDm0ZllZ+1D1/FKTH3PhjNDg5DrHyrfXkI0tMUmuWzYYH2 hqjofWA8aEN0miJ1gJjqp2l8OILbEPmLqJ/mi6WJzM/d2b8iKlpSNk9SsmtCfQMz+cOv NshR9t8nYBupXVwapcwOLEQiccUyRHfpuvoNKNG/so07qy4s4V5lr88UWFGeuQb5NRfV 2Kiqq8WZHeZORojHCwXxBY1njuNb24bVyrsF4cewqmhA7V7zkkhpl1OQAL+zJ1wV+fLj D1iPbfyY3Rc1pUhYuBB1zEEDCiPNskK4kMMpfSou3Rm0WhOcajSKrWkDRWCQMAMQbmlQ i14g== MIME-Version: 1.0 X-Received: by 10.42.140.72 with SMTP id j8mr989069icu.37.1359030583220; Thu, 24 Jan 2013 04:29:43 -0800 (PST) In-Reply-To: <510124A5.6080701@tobix.eu> References: <51011822.3020702@tobix.eu> <510121F9.70508@tobix.eu> <510124A5.6080701@tobix.eu> Date: Thu, 24 Jan 2013 13:29:43 +0100 Subject: Re: using split for a string : error From: inshu chauhan To: "Tobias M." Content-Type: multipart/alternative; boundary=90e6ba6e8be826db8704d407f7ea Cc: "python-list@python.org" 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: 114 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1359030591 news.xs4all.nl 6908 [2001:888:2000:d::a6]:52510 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37582 --90e6ba6e8be826db8704d407f7ea Content-Type: text/plain; charset=ISO-8859-1 Thanks a lot people.. :).. :) On Thu, Jan 24, 2013 at 1:10 PM, Tobias M. wrote: > Am 24.01.2013 13:02, schrieb Chris Angelico: > > On Thu, Jan 24, 2013 at 10:58 PM, Tobias M. wrote: >> >>> Chris Angelico wrote: >>> >>>> I'd not consider the performance, but the correctness. If you're >>>> expecting them to be integers, just cast them, and specifically >>>> _don't_ catch ValueError. Any non-integer value will then noisily >>>> abort the script. (It may be worth checking for blank first, though, >>>> depending on the data origin.) >>>> >>> Well, when I said you should catch the ValueError I didn't imply you >>> should >>> ignore the error and supress any error messages. Of course this depents >>> on >>> the use case. Maybe you want to raise another exception with a more user >>> friendly error message or you might want to skip the line and just print >>> a >>> warning. :) >>> >>> What I'm trying to say: When I give a script/program to a user who is >>> not a >>> python programmer I don't want him to see an error message like >>> "ValueError: >>> invalid literal for int() with base 10: 'abc'" as this would help him in >>> no >>> way. >>> >> Sure. Definitely. But for a proglet where the programmer IS the user >> (which I think is one of Python's best use-cases), that exception >> landing on the console is better than having to think ahead of time >> about what might go wrong. >> >> ChrisA >> > Okay, I absolutely agree with that :) > > Tobias > -- > http://mail.python.org/**mailman/listinfo/python-list > --90e6ba6e8be826db8704d407f7ea Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks a lot people.. :).. :)



On Thu, Jan 24, 2013 at 1:1= 0 PM, Tobias M. <tm@tobix.eu> wrote:
Am 24.01.2013 13:02, schrieb Chris Angelico:=

On Thu, Jan 24, 2013 at 10:58 PM, Tobias M. <tm@tobix.eu> wrote:
Chris Angelico wrote:
I'd not consider the performance, but the correctness. If you're expecting them to be integers, just cast them, and specifically
_don't_ catch ValueError. Any non-integer value will then noisily
abort the script. (It may be worth checking for blank first, though,
depending on the data origin.)
Well, when I said you should catch the ValueError I didn't imply you sh= ould
ignore the error and supress any error messages. Of course this depents on<= br> the use case. Maybe you want to raise another exception with a more user friendly error message or you might want to skip the line and just print a<= br> warning. :)

What I'm trying to say: When I give a script/program to a user who is n= ot a
python programmer I don't want him to see an error message like "V= alueError:
invalid literal for int() with base 10: 'abc'" as this would h= elp him in no
way.
Sure. Definitely. But for a proglet where the programmer IS the user
(which I think is one of Python's best use-cases), that exception
landing on the console is better than having to think ahead of time
about what might go wrong.

ChrisA
Okay, I absolutely agree with that :)

Tobias
--
http://mail.python.org/mailman/listinfo/python-list

--90e6ba6e8be826db8704d407f7ea--