Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'advocate': 0.07; 'subject:help': 0.08; 'except:': 0.09; 'input,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'style.': 0.09; 'terminates': 0.09; 'try:': 0.09; '>on': 0.16; 'emit': 0.16; 'emits': 0.16; 'message-id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sys.exit(1)': 0.16; 'terminate.': 0.16; 'values?': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'programming': 0.22; 'print': 0.22; 'error': 0.23; 'url:home': 0.24; 'header:X -Complaints-To:1': 0.27; 'idea': 0.28; 'chris': 0.29; 'am,': 0.29; 'comment': 0.34; 'test': 0.35; 'really': 0.36; 'useful': 0.36; 'charset:us-ascii': 0.36; 'generic': 0.38; 'to:addr:python-list': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'simply': 0.61; "you're": 0.61; 'note:': 0.66; 'default': 0.69; 'received:108': 0.93; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Efficency help for a Calculator Program Date: Thu, 03 Oct 2013 19:15:44 -0400 Organization: IISS Elusive Unicorn References: <77bde84a-b0ce-4061-bb2e-e6cd23f4282c@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-68-176-115.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1380842159 news.xs4all.nl 15917 [2001:888:2000:d::a6]:40318 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:55446 On Thu, 3 Oct 2013 10:25:47 +1000, Chris Angelico declaimed the following: >On Thu, Oct 3, 2013 at 9:47 AM, Dennis Lee Bieber 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. -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/