Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!newsfeed0.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: can try expect have if else. Date: Mon, 22 Feb 2016 04:07:05 +1100 Lines: 23 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de aYw+mv2h876zTbImWi+IOgNmmcnPefgnoEh510Z7aiUA== Cancel-Lock: sha1:HcLd/5NO4ch/oewb+fhq7gZ11lA= Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.053 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'reached.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'code?': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; '(the': 0.22; 'code.': 0.23; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'sequence': 0.27; 'raise': 0.29; 'code': 0.30; 'statement': 0.32; 'rule': 0.33; 'except': 0.34; 'running': 0.34; 'false': 0.35; 'something': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'received:org': 0.37; 'expressed': 0.39; 'skip:e 20': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'improved': 0.63; 'you.': 0.64; 'intent': 0.66; 'percent': 0.66; 'subject:have': 0.80; '_o__)': 0.84; 'received:125': 0.84; 'subject:try': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) 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:103308 Ganesh Pal writes: > 1. Can we have if else with in a try except block What result do you get when running that code? What empirical reason do you have to think it would work or not work? > 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 ‘return‛ statement will never be reached. So your intent must be something other than what is expressed by that code. -- \ “Do unto others twenty-five percent better than you expect them | `\ to do unto you. (The twenty-five percent is [to correct] for | _o__) error.)” —Linus Pauling's Golden Rule | Ben Finney