Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Joel Goldstick Newsgroups: comp.lang.python Subject: Re: common mistakes in this simple program Date: Mon, 29 Feb 2016 15:26:16 -0500 Lines: 31 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de qzvJOrblgZ81TOX0fT+R3ABbKmJeyWjL0crD99hI/kYg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; 'cc:addr:python-list': 0.09; 'loop.': 0.09; 'exception': 0.13; 'ignore': 0.14; '2016': 0.16; 'clause,': 0.16; 'handling.': 0.16; 'received:209.85.223.173': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:program': 0.16; 'subject:simple': 0.16; 'trap': 0.16; 'wrote:': 0.16; 'later': 0.16; '>': 0.18; 'email addr:gmail.com>': 0.18; 'cc:addr:python.org': 0.20; 'cc:2**1': 0.22; 'assuming': 0.22; 'exceptions': 0.22; 'am,': 0.23; 'feb': 0.23; 'wrote': 0.23; 'cc:addr:gmail.com': 0.24; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'message-id:@mail.gmail.com': 0.27; 'see,': 0.27; 'url:moin': 0.27; 'this.': 0.28; 'for,': 0.29; 'url:wiki': 0.30; 'url:mailman': 0.30; 'option': 0.31; 'url:python': 0.33; 'url:listinfo': 0.34; 'except': 0.34; 'received:google.com': 0.35; 'instead': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'received:209': 0.38; 'sure': 0.39; 'url:mail': 0.40; 'ever': 0.60; 'mar': 0.65; 'else.': 0.66; 'here': 0.66; 'url:info': 0.71; 'ruled': 0.84; 'subject:common': 0.84; 'subject:this': 0.85; 'to:none': 0.91; 'joel': 0.91 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:cc; bh=1CdbryNRUK5Xyk1wvF5Ebev6uW1jbp5vsxLNLuAQqjI=; b=mbLJQ7zyQucet4PYEf088GNCVyZXlLS4vx4+dwB7MDFPNVOm5wgYvom+P1XCCZk2mQ 7Yk3xMGMhiipNdotTtKbTdiRpqiH6CQs3cya5k/K3ybJOHTJ0XfxGuJM8ygC5f3vMo/p 4emjWNats/Yek3FkUpTEUrMx38frBIfduRcBCRaMSR0YGb26rNEwICbyZu4g+cUViRbI 7/puE/8C1MaWbk6PTT+NM4Sv/zb7uITDEajKakfYIMOO9bXwtg/CoQCJL6zqrG3hoAyD KFbEtKnt1Z/0Sh8/ibSJBYyDhu27ZpU6YZOMqlP8+Sf3F2Wk9TBih2Wup4bO9t29ZWlT lzsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=1CdbryNRUK5Xyk1wvF5Ebev6uW1jbp5vsxLNLuAQqjI=; b=iPypRibL1N41QF5WpQUx6vE0JFApu6NGdaziD19VqnEZQVlt7sNMOGMDRwX/rjo/U9 OhMjGBkogwUdwbg5yM856WphsmhxbnglOPaXBsKZigjnVmPDU3pffOZz/dqgmG1GJkz4 YEn2giBg5B+RJvHeSvtbtA0hbxc1EL3qEm3XhODxoATBmeTv18DF31L4UGpDdROi7qRi enOrs+jvBwbY6RUrzF5R1Hz+3PZVEr92w0AouIZoUfym6igfbmpJlo1FlTY1UOlNQ1JU Xqz5YI84+RMrKcHDGrbWtjGPSnGgxZ1T+bwlPFLwxIzC1BpK77bGqQso/+gVsSKOxEX9 oRwQ== X-Gm-Message-State: AG10YOQ4HgShZTAFz7Nz23aHtXCx9V/Bf1MXagLdjjLeJfIekJrEBFO69NzHopqhJTci+vQnVOIzU44VkI22Jg== X-Received: by 10.107.62.195 with SMTP id l186mt23488093ioa.180.1456777576582; Mon, 29 Feb 2016 12:26:16 -0800 (PST) In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103756 On Mon, Feb 29, 2016 at 2:49 PM, Ganesh Pal wrote: > On Mar 1, 2016 12:06 AM, "Chris Angelico" wrote > > > > You're falling into the trap of assuming that the only exception you > > can ever get is the one that you're planning for, and then handling. > > Ok sure ! > > > ALL exceptions as though they were that one. Instead catch ONLY the > > exception that you're expecting to see, and ignore everything else. Do > > not use a bare "except:" clause, nor even "except Exception:", for > > this. You will appreciate it later on. > > What option do I have now in so ensure that I loop over the For loop. Try > except is ruled out ? > Its not ruled out. It is pointless. Look at the documents. Here is a start: https://wiki.python.org/moin/HandlingExceptions > -- > https://mail.python.org/mailman/listinfo/python-list > -- Joel Goldstick http://joelgoldstick.com/ http://cc-baseballstats.info/