Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100443

Re: Try: rather than if :

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Vincent Davis <vincent@vincentdavis.net>
Newsgroups comp.lang.python
Subject Re: Try: rather than if :
Date Mon, 14 Dec 2015 17:20:57 -0700
Lines 17
Message-ID <mailman.9.1450138879.22044.python-list@python.org> (permalink)
References <CALyJZZViT33d8iob-5PoYnJOdPU2RzSzt3YAic_GRaAxN+wE1A@mail.gmail.com> <20151214231420.GA20631@cskk.homeip.net> <CALyJZZWn-UJPkMtNOBX9YcvAmWgA4qTo7_LwhHjciwevmrn1xw@mail.gmail.com> <CALwzid=32c_ELw5=-LY9ad8yrCPCMrqnaU2Z9QfvceCFZ7rOQQ@mail.gmail.com>
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 <vincent@vincentdavis.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; '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&gt;': 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 <CALwzid=32c_ELw5=-LY9ad8yrCPCMrqnaU2Z9QfvceCFZ7rOQQ@mail.gmail.com>
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 <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>
Xref csiph.com comp.lang.python:100443

Show key headers only | View raw


On Mon, Dec 14, 2015 at 4:53 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:

>
> Except that catching an exception just to immediately re-raise it is
> silly. This would be better:
>
> try:
>     name = handle.name
> except AttributeError:
>     pass
> else:
>     handle.write("# Report_file: %s\n" % name)


​Ya that would be silly.

Thanks​ everyone for the education.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Try: rather than if : Vincent Davis <vincent@vincentdavis.net> - 2015-12-14 17:20 -0700

csiph-web