Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!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.058 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'cc:addr:python-list': 0.11; 'python': 0.11; 'question.': 0.14; '*only*': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'responses.': 0.16; 'situation.': 0.16; 'sorts': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'otherwise,': 0.22; 'cc:addr:python.org': 0.22; 'decide': 0.24; 'file.': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'that.': 0.31; 'exceptions': 0.31; 'file': 0.32; 'run': 0.32; 'up.': 0.33; 'fri,': 0.33; 'received:google.com': 0.35; 'thanks': 0.36; 'should': 0.36; 'application': 0.37; 'pm,': 0.38; 'how': 0.40; 'catch': 0.60; 'kind': 0.63; 'more': 0.64; 'here': 0.66; 'reads': 0.68; '2015': 0.84; 'clauses,': 0.84; 'console,': 0.84; 'to:none': 0.92 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 :content-type; bh=qQsdHbiOpIDlYvE6Y1y68dBhOexliT+lqFFei7q08xs=; b=iCQHUivzltH2a3Uvyz4v6htsFWqHN4PO4uSNGhrzeIzQz+EtZDUX7wVSJcj1hrG7g5 9VDsXZCuP62Bf72PIYQUHeCEopTUfSgCwUL+5vruqh8esVaBruRo0kZshOnlCxMYmrok jKNHsjZPYPz3EX0YltTq7Ixikwl1ofilSgVg0FczkFDGePPJ7SEkjjgvl0VWiOta7f2g 9EQ7rixdtzzz5184XqeDRfIX83FyszpzzVJp8tID+6742VbnnHbyHUmJ0THiacZxMuG6 s2G7Pp5aouj5L+C0rYZdNLKCD4KYMVDuPSZI+q42mSyvc6wpnUWMZP0IB2obqaK1BgQX MuUg== MIME-Version: 1.0 X-Received: by 10.107.134.206 with SMTP id q75mr801269ioi.27.1428656401391; Fri, 10 Apr 2015 02:00:01 -0700 (PDT) In-Reply-To: <1cd0a97d-96c7-4ee6-9cfe-c0e90b9baa55@googlegroups.com> References: <1cd0a97d-96c7-4ee6-9cfe-c0e90b9baa55@googlegroups.com> Date: Fri, 10 Apr 2015 19:00:01 +1000 Subject: Re: Exception Handling From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20 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: 13 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1428656403 news.xs4all.nl 2865 [2001:888:2000:d::a6]:45810 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88774 On Fri, Apr 10, 2015 at 6:39 PM, Palpandi wrote: > Thanks for your responses. And I have one more question. > > This is the situation. A python application which reads data from one .xml file and generates some other file. Here what kind of exceptions occur? All sorts of exceptions. The best way to find out is to write your code without any try/except clauses, and then run it. When an exception happens, it'll be printed out on the console, and the program terminated. Then you can decide how your program should cope with that. Catch an exception *only* if you can actually deal with it inside your code; otherwise, just let it bubble up. ChrisA