Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Ganesh Pal Newsgroups: comp.lang.python Subject: Re: common mistakes in this simple program Date: Tue, 15 Mar 2016 21:26:18 +0530 Lines: 19 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de ODGkzdSqGS3uSeyl+9oThA9WwqKo2LdTe0e391xE+A8g== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.031 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'python': 0.10; 'exception': 0.13; '2016': 0.16; 'already,': 0.16; 'exceptions.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:program': 0.16; 'subject:simple': 0.16; 'to:addr:martin': 0.16; 'wrote:': 0.16; 'shell': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'martin': 0.22; 'am,': 0.23; 'demonstrate': 0.23; 'tried': 0.24; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'message-id:@mail.gmail.com': 0.27; 'classes': 0.30; "i'll": 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'step': 0.36; 'but': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'seem': 0.37; 'received:209': 0.38; 'several': 0.38; 'well.': 0.40; 'easy': 0.60; 'skip:u 10': 0.61; 'different': 0.63; 'mar': 0.65; 'below.': 0.66; 'subject:common': 0.84; 'try,': 0.84; 'subject:this': 0.85; 'gaps': 0.93 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 :cc; bh=8ZZGDXePn8xqUu606O7vnoPNSotcvGgsNJ056lPBq64=; b=VD1qSjsppUxaawce1NAKULd5kLhNXyrWdoRla+7g7QDGVxL5Qp9LOoxqrY6Hn7jc8B XoSpMcwUz1rAQWuVLIGW3nVXkNtt+x8asWQ/CBD+B1WlMBsgc4IN4FPEMurpTYG7wQbP ih001cK00qQEMK2kZG2Ymfelbj+eWmGEjxcTA9LMipoV5UcjFs4RIf2iU4+0JFuIsU88 LVIMCk7XTLIv64mp5kOaY8HYrhKwm9DMNgw8nCHmVgr+OYy7kM7Zm2NKx3PeyuSyZR+1 L2QEzotwdmRcDVV0RAus4y8HMK2ZiTFT3yldYCmAP4v8HRgCrzORi+qPPaz3JvPavCdr xnGw== 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:to:cc; bh=8ZZGDXePn8xqUu606O7vnoPNSotcvGgsNJ056lPBq64=; b=VFkJyX2G3mW2bUHBz/E5saaQoRR0MleeQHEJkFmfRfmihlVkkGCWUnofSscQdRGdUA AE8sMsLn8nX0qJr5rUNoMzhIed91Nkf1izZr/OsNYzQ0hqD4gOb9NL4/kL9pzapryYaB oTAsl2iJRXZAbj31tYeoCrS5On3QbSr/Z2W8o6YaYb69O9e1ZKRddX1TL+xJA7a8iIpc W/YLlF0eV9FfLjIGEewUB/pnQD8bbv7eHAxmPVYdGuUjWy1EOl0KrXbH7eaOMgl49va/ pucipWn6LFFCYb8AwJqlg8oBF5zgkrkMcESu5tKLpNU59O4TLSlXbI+cXPAVkNIg1osZ M7SQ== X-Gm-Message-State: AD7BkJKgNybVyZ6dZksUYwtF2CXp6cuLqRFqgKilzUeU/ixigfSqkn6+u2OPHQu2Q+gJqSP9Zp+kLV1LtcSCig== X-Received: by 10.25.206.135 with SMTP id e129mr10554686lfg.46.1458057379053; Tue, 15 Mar 2016 08:56:19 -0700 (PDT) In-Reply-To: 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:104944 On Tue, Mar 1, 2016 at 2:41 AM, Martin A. Brown wrote: > Please read below. I will take a stab at explaining the gaps of > understanding you seem to have (others have tried already, but I'll > try, as well). > > I am going to give you four different functions which demonstrate > how to use exceptions. You may find it instructive to paste these > functions into an interactive Python shell and try them out, as > well. > Thanks Martin for beautifully demonstrating the use of exception with an example that's easy to understand. Step 1: catch a specific Exception Step 2: catch a specific Exception Step 3: catch several different classes of Exception Step 4: catch many different classes of Exception