Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ganesh Pal Newsgroups: comp.lang.python Subject: Re: can try expect have if else. Date: Sun, 21 Feb 2016 23:09:30 +0530 Lines: 37 Message-ID: References: <858u2e0z7q.fsf@benfinney.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de FeVLrKmZyLAebW+UuKQO9AeAIhk0lG7CkeH1XKfajEhA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; '21,': 0.07; 'cc:addr :python-list': 0.09; 'func': 0.09; 'reached.': 0.09; 'exception': 0.13; '2016': 0.16; 'code?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'try:': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'programming': 0.22; 'code.': 0.23; 'feb': 0.23; 'header:In-Reply-To:1': 0.24; 'checking': 0.27; 'message-id:@mail.gmail.com': 0.27; 'sequence': 0.27; 'function': 0.28; 'raise': 0.29; 'code': 0.30; 'skip:[ 10': 0.31; 'statement': 0.32; 'recommended': 0.34; 'except': 0.34; 'running': 0.34; 'received:google.com': 0.35; 'false': 0.35; 'returning': 0.35; 'something': 0.35; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'wanted': 0.37; 'received:209': 0.38; 'expressed': 0.39; 'skip:e 20': 0.39; 'your': 0.60; 'avoid': 0.61; 'improved': 0.63; 'more': 0.63; 'intent': 0.66; 'subject:have': 0.80; 'subject:try': 0.84 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:content-type:content-transfer-encoding; bh=rtRBBmqCfgOnCtqPx2odZpjtxLW89tx6JTITCo0u80Q=; b=XsXqj8X+D8DYFo35LapiaCk7DwMBpOQOWMOIX+tCXuekMAFO2cu9slZtGUPrXZf0Fq Mxnyf5pxmpR0DyXjQaCYAj/R2pKHKxgPjFQSPF+m1iiOdIdAEdZM9btDZd1b5HUrQcfo yNWTMuuZ/rcL9UTmb01QBaZOGJ3J3NXwrB1wuAsr4GJ+vt1dXpG4tM3P4ufoyImdd3Xb iCZ52+Ykd3ITz0xpRV0bkXkQKkPP1jI39QKaxVO28zm5e55KlamgrjwIcj4Re1ly53Wh pfXMogXMDyvEcq4e4IdK9smvkhFwXTyYcITQl2iU807ppIVFss5fG3r1PoRBJ9SU6Sw2 0dZA== 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:content-type :content-transfer-encoding; bh=rtRBBmqCfgOnCtqPx2odZpjtxLW89tx6JTITCo0u80Q=; b=XYPvto7mcb446vbzwFjO6xMQNkZN2CwVW57FypN2Cb69w0wMz15aakSFK6/v3MUmWF TwamHgp6KtTP4WCUI6+ZlSLK3FbZ7GkRaRNlwRx3zuPcQQ+xLigSIGlON8dfyjZbKEi6 24pOz/wLZeM5MbgketdZ9tNSr5dSOqC0v4XQl1CmMX0Zu8bQJkRYYtVG/Xbcc+tvxXGf 6EkeAcUuSgwq1FFISNcndIQRQCtFg0zH/N8iYivgbkSLn5BhjTZZPySKr3xXlMDk8pbg +kl8ZMEpqIzMB7ixLjNS7fSTc5WRWgwbnQz3pRLg7KLhaGYpxlJTCB1BcjzM2uf/ABM5 mgvg== X-Gm-Message-State: AG10YORfh40ioh1NIM64O/qF+o2UfI9AbvCTWCsC0826tF31pyxl1Mq+yWWrwQp83dfNEsYJHMoMyjGoh7Ae1A== X-Received: by 10.25.167.74 with SMTP id q71mr8859013lfe.24.1456076371039; Sun, 21 Feb 2016 09:39:31 -0800 (PST) In-Reply-To: <858u2e0z7q.fsf@benfinney.id.au> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 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:103310 On Sun, Feb 21, 2016 at 10:37 PM, Ben Finney w= rote: > What result do you get when running that code? What empirical reason do > you have to think it would work or not work? I wanted to know was is it good to have if else with in a try expect block , I was checking more from the programming perspective and if I need to avoid it and if its recommended >> 2. How can the above code be improved > > The following sequence of statements:: > > raise Exception("/nfs_mount is not mounted. Dataset create failed !!!= ") > return False > > do not make sense. The =E2=80=98return=E2=80=9B statement will never be r= eached. So your > intent must be something other than what is expressed by that code. > I was using it with create_data function in the below code . If create_dataset failed the exception would be caught , I think you are right I need not worry about returning False functions =3D [create_logdir, create_dataset] for func in functions: try: func() except Exception as e: logging.error(e) return False Regards, Ganesh