Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37575 > unrolled thread

Re: using split for a string : error

Started by"Tobias M." <tm@tobix.eu>
First post2013-01-24 12:58 +0100
Last post2013-01-24 12:58 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: using split for a string : error "Tobias M." <tm@tobix.eu> - 2013-01-24 12:58 +0100

#37575 — Re: using split for a string : error

From"Tobias M." <tm@tobix.eu>
Date2013-01-24 12:58 +0100
SubjectRe: using split for a string : error
Message-ID<mailman.972.1359028732.2939.python-list@python.org>
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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web