Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #37582
| References | (2 earlier) <51011822.3020702@tobix.eu> <CAPTjJmrqD7-x_sG_g-9YFFDanOct6_Grdw374EB69Kxy57LwLQ@mail.gmail.com> <510121F9.70508@tobix.eu> <CAPTjJmqJKwtE-N2MVfa2ATRFSiMipvrydJd8_=1fqob2AmgiZA@mail.gmail.com> <510124A5.6080701@tobix.eu> |
|---|---|
| Date | 2013-01-24 13:29 +0100 |
| Subject | Re: using split for a string : error |
| From | inshu chauhan <insideshoes@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.978.1359030591.2939.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
Thanks a lot people.. :).. :) On Thu, Jan 24, 2013 at 1:10 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 >>> 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<http://mail.python.org/mailman/listinfo/python-list> >
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: using split for a string : error inshu chauhan <insideshoes@gmail.com> - 2013-01-24 13:29 +0100
csiph-web