<div dir="ltr">Thanks a lot people.. :).. :) <br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jan 24, 2013 at 1:10 PM, Tobias M. <span dir="ltr"><<a href="mailto:tm@tobix.eu" target="_blank">tm@tobix.eu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Am 24.01.2013 13:02, schrieb Chris Angelico:<div><div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Thu, Jan 24, 2013 at 10:58 PM, Tobias M. <<a href="mailto:tm@tobix.eu" target="_blank">tm@tobix.eu</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Chris Angelico wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'd not consider the performance, but the correctness. If you're<br>
expecting them to be integers, just cast them, and specifically<br>
_don't_ catch ValueError. Any non-integer value will then noisily<br>
abort the script. (It may be worth checking for blank first, though,<br>
depending on the data origin.)<br>
</blockquote>
Well, when I said you should catch the ValueError I didn't imply you should<br>
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<br>
friendly error message or you might want to skip the line and just print a<br>
warning. :)<br>
<br>
What I'm trying to say: When I give a script/program to a user who is not a<br>
python programmer I don't want him to see an error message like "ValueError:<br>
invalid literal for int() with base 10: 'abc'" as this would help him in no<br>
way.<br>
</blockquote>
Sure. Definitely. But for a proglet where the programmer IS the user<br>
(which I think is one of Python's best use-cases), that exception<br>
landing on the console is better than having to think ahead of time<br>
about what might go wrong.<br>
<br>
ChrisA<br>
</blockquote></div></div>
Okay, I absolutely agree with that :)<span class="HOEnZb"><font color="#888888"><br>
<br>
Tobias<br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div>