Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!feeder1.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feed.tweaknews.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; '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; 'programmer': 0.11; 'subject:error': 0.11; 'ignore': 0.13; '24,': 0.16; 'correctness.': 0.16; 'integers,': 0.16; 'landing': 0.16; 'received:188.40.28': 0.16; 'received:your-server.de': 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; "python's": 0.23; 'raise': 0.24; 'specifically': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; '(which': 0.26; 'checking': 0.27; 'first,': 0.27; 'chris': 0.28; "i'm": 0.29; 'maybe': 0.29; 'subject: : ': 0.30; 'error': 0.30; 'print': 0.32; 'to:addr:python-list': 0.33; 'another': 0.33; 'agree': 0.34; 'ahead': 0.35; 'pm,': 0.35; 'but': 0.36; "didn't": 0.36; 'should': 0.36; 'data': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'help': 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 Date: Thu, 24 Jan 2013 13:10:13 +0100 From: "Tobias M." User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: python-list@python.org Subject: Re: using split for a string : error References: <51011822.3020702@tobix.eu> <510121F9.70508@tobix.eu> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-Sender: tm@tobix.eu X-Virus-Scanned: Clear (ClamAV 0.97.5/16562/Thu Jan 24 00:40:16 2013) 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1359029415 news.xs4all.nl 6958 [2001:888:2000:d::a6]:46163 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:37579 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