Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Vincent Davis Newsgroups: comp.lang.python Subject: Re: Try: rather than if : Date: Mon, 14 Dec 2015 17:20:57 -0700 Lines: 17 Message-ID: References: <20151214231420.GA20631@cskk.homeip.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de X0Jq3kOrCYUJGrYNQCM4zAnsGD47eNmkPUdr1NmVNt4g== Return-Path: 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; 'else:': 0.03; '%s\\n"': 0.09; 'name)': 0.09; 'received:209.85.218': 0.10; 'exception': 0.13; 'better:': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'try:': 0.18; 'email addr:gmail.com>': 0.18; '2015': 0.20; 'pass': 0.22; 'dec': 0.23; 'header:In-Reply- To:1': 0.24; 'mon,': 0.24; 'message-id:@mail.gmail.com': 0.27; '14,': 0.27; 'catching': 0.29; 'everyone': 0.31; 'except': 0.34; 'received:google.com': 0.35; 'received:209.85': 0.36; 'to:addr :python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'to:addr:python.org': 0.40; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vincentdavis.net; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=ZD6XyeqssCYZzvvW+tv+mzf26OV4/Vj+yM+xaL1jOGM=; b=hIFW5My1LFsZFqjTbOL+v/InEnhFXCmiYo70V/Bhp/5wyPUAs5cpQu9arOBinIbAe2 Hp1h8gZ3m144/CAMoj6f798Xf0rr17g2cecEpqPkiPpbxjekly/zvGh5mex8iTN0ifMk yJIcf9TowrxwjpGVZFNp1MASIK2EaFrG1ppM0= 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:from:date :message-id:subject:to:content-type; bh=ZD6XyeqssCYZzvvW+tv+mzf26OV4/Vj+yM+xaL1jOGM=; b=gSb03du3hzUdfhkJQoQLLLvhxc5hyq52wrrxaweTAmE29tgWaBhTYwpY/X1I1ZT3IG N7eVn4I/PCypZmFjW9d73BK00AWzgL7SQgRlVHO44usB53gUgJbZ08/o5Vo5+1mb7ZGM JS4i1C8J4Q+l57JkDzwjqwNVn72YBn5Pb102l78t44jl57F1iQLT0C/LlB98ZBBU2mAc irYToYUaYydkYp5+tUUZj089sCIuBAytf0y2F0dDjzyMOdYWamgE/nv6vA1h+UzmskWq uyo0KahsUSN4DBP6QhaCzlqeyRHZbNwSeS3mG86EbVQSo0BCff6OjnW5rBGUdVUbiGdk HLXg== X-Gm-Message-State: ALoCoQm0zl3M6CqZ4m5LNMGTHDlr59bxZjQuIa8KMmf7y1nNN5kPQAm/6FGuf6aGfu8/bGDjOl7TwFTnhs2L8tBAfXulHGJyXfLXyKq2gAFBGQ66f+odmyE= X-Received: by 10.202.208.68 with SMTP id h65mr26745780oig.111.1450138876671; Mon, 14 Dec 2015 16:21:16 -0800 (PST) In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.20+ 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: , Xref: csiph.com comp.lang.python:100443 On Mon, Dec 14, 2015 at 4:53 PM, Ian Kelly wrote: > > Except that catching an exception just to immediately re-raise it is > silly. This would be better: > > try: > name =3D handle.name > except AttributeError: > pass > else: > handle.write("# Report_file: %s\n" % name) =E2=80=8BYa that would be silly. Thanks=E2=80=8B everyone for the education.