Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #55393
| References | <77bde84a-b0ce-4061-bb2e-e6cd23f4282c@googlegroups.com> <gdap49lskt6b1ph9rf3devk52mq5mqphnr@4ax.com> |
|---|---|
| Date | 2013-10-03 10:25 +1000 |
| Subject | Re: Efficency help for a Calculator Program |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.663.1380759957.18130.python-list@python.org> (permalink) |
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.
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next 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