Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #55453
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'advocate': 0.07; 'subject:help': 0.08; 'clause': 0.09; 'except:': 0.09; 'input,': 0.09; 'style.': 0.09; 'terminates': 0.09; 'try:': 0.09; '9:15': 0.16; '>>on': 0.16; 'emit': 0.16; 'emits': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'sys.exit(1)': 0.16; 'terminate.': 0.16; 'values?': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'thu,': 0.19; '>>>': 0.22; 'programming': 0.22; 'separate': 0.22; 'print': 0.22; 'error': 0.23; "shouldn't": 0.24; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'chris': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'fri,': 0.33; 'comment': 0.34; 'except': 0.35; 'done.': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'useful': 0.36; 'two': 0.37; 'generic': 0.38; 'writes': 0.38; 'to:addr:python- list': 0.38; 'fact': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; 'issues,': 0.61; 'mentioned': 0.61; 'simply': 0.61; "you're": 0.61; 'more': 0.64; 'note:': 0.66; 'default': 0.69; 'bare': 0.84; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=T7ofyc74KWMQbDIxtuyxoVN+S55I3iNy988WQCrHpAM=; b=YxHUsC6Y66V/xTLsP3vjb/8xE8N+6IfuL7LBR/Jt4DQfcpcPecfSi2Hh1USjce9h/n Oas4gD4OHBSJl7cv4jLjFmtcQ0YVzPjrRo/ewgH5920fRpLtYkykjQmseQ2NTt9YrMWS EtP0fB8ZRwgIJV7bafTUcvC5wLxZuX3tYCNX+6069xGbKWHPIFl3Mdx85/rlTXJwY34m rGJXO/AijDJhEBU9MoKwFE3hlFfOOKB0E8ha5UASlQKkaJXsL+IXftFyInq9pIJGPDak w5yVFKnrkdJo+HXTd8yNMpIbMWXoNrq/VCez4LM0rHB0UcmhjxO6foMCIFltrWEzmSr+ BxnA== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.231.71 with SMTP id te7mr44982pbc.203.1380869151244; Thu, 03 Oct 2013 23:45:51 -0700 (PDT) |
| In-Reply-To | <gjur49pj7qofes9kbjhv5c3acddufuvvju@4ax.com> |
| References | <77bde84a-b0ce-4061-bb2e-e6cd23f4282c@googlegroups.com> <gdap49lskt6b1ph9rf3devk52mq5mqphnr@4ax.com> <CAPTjJmpDatnEV-cyx7Bcw_dW7AZphv5U62xWu=b9+8NhW_58bg@mail.gmail.com> <gjur49pj7qofes9kbjhv5c3acddufuvvju@4ax.com> |
| Date | Fri, 4 Oct 2013 16:45:51 +1000 |
| Subject | Re: Efficency help for a Calculator Program |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.708.1380869161.18130.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1380869161 news.xs4all.nl 15887 [2001:888:2000:d::a6]:39753 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:55453 |
Show key headers only | View raw
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