Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #55453
| References | <77bde84a-b0ce-4061-bb2e-e6cd23f4282c@googlegroups.com> <gdap49lskt6b1ph9rf3devk52mq5mqphnr@4ax.com> <CAPTjJmpDatnEV-cyx7Bcw_dW7AZphv5U62xWu=b9+8NhW_58bg@mail.gmail.com> <gjur49pj7qofes9kbjhv5c3acddufuvvju@4ax.com> |
|---|---|
| Date | 2013-10-04 16:45 +1000 |
| Subject | Re: Efficency help for a Calculator Program |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.708.1380869161.18130.python-list@python.org> (permalink) |
On Fri, Oct 4, 2013 at 9:15 AM, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
> On Thu, 3 Oct 2013 10:25:47 +1000, Chris Angelico <rosuav@gmail.com>
> declaimed the following:
>
>>On Thu, Oct 3, 2013 at 9:47 AM, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
>>> try:
>>> numItems = int(raw_input("\n\nHow many values? "))
>>> except: #naked exception is not really good programming
>>> print "Invalid input, exiting..."
>>> sys.exit(1)
>>
>>Please don't _ever_ advocate this programming style! Wrapping
>>something in a try/except that emits a generic message and terminates
>>is a bad idea - the default behaviour, if you simply let the exception
>>happen, is to emit a very useful message and terminate. Never test for
>>any error condition you're not prepared to handle, as the BOFH advised
>>his boss.
>>
> Note: I DID include a comment that this was NOT good style.
You mentioned that bare except is a problem; I'm more looking at the
fact that the except clause simply writes a message and terminates.
They're two separate issues, both bad style.
I know _you_ know it's bad style; but someone reading over this needs
to be aware that this shouldn't normally be done.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Efficency help for a Calculator Program JonDoe297 <vignesh.harikrishna@gmail.com> - 2013-10-02 03:44 -0700
Re: Efficency help for a Calculator Program Chris Angelico <rosuav@gmail.com> - 2013-10-02 21:01 +1000
Re: Efficency help for a Calculator Program JonDoe297 <vignesh.harikrishna@gmail.com> - 2013-10-02 06:43 -0700
Re: Efficency help for a Calculator Program Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-02 19:47 -0400
Re: Efficency help for a Calculator Program Chris Angelico <rosuav@gmail.com> - 2013-10-03 10:25 +1000
Re: Efficency help for a Calculator Program Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-10-03 19:15 -0400
Re: Efficency help for a Calculator Program Chris Angelico <rosuav@gmail.com> - 2013-10-04 16:45 +1000
csiph-web