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


Groups > comp.lang.python > #103315

Re: can try expect have if else.

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Newsgroups comp.lang.python
Subject Re: can try expect have if else.
Date Sun, 21 Feb 2016 13:49:14 -0500
Organization IISS Elusive Unicorn
Lines 45
Message-ID <mailman.22.1456080563.20994.python-list@python.org> (permalink)
References <CACT3xuWMtxjC+6idsj_RfWVXLS-QCzQSdGaj2Kk4g4_EH9_wPA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de n/RHH9Aqe2rmjd0Rtoc2CwdTRuwk4O6edGBCWD9PkEPg==
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; '"""': 0.05; 'caller': 0.07; 'exits': 0.09; 'message-id:@4ax.com': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; 'exception': 0.13; '2016': 0.16; 'itself;': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'skip:> 20': 0.16; 'succeeds,': 0.16; 'result,': 0.18; 'try:': 0.18; 'url:home': 0.18; 'team,': 0.18; 'input': 0.18; 'code.': 0.23; 'feb': 0.23; "doesn't": 0.26; 'header:X-Complaints-To:1': 0.26; '2.6': 0.27; 'executing': 0.27; 'function': 0.28; 'raise': 0.29; 'except': 0.34; 'gets': 0.35; 'false': 0.35; 'there': 0.36; 'success.': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'charset:us-ascii': 0.37; 'test': 0.39; 'skip:e 20': 0.39; 'to:addr:python.org': 0.40; 'reached': 0.60; 'real': 0.62; 'back': 0.62; 'transfer': 0.73; 'subject:have': 0.80; '>def': 0.84; 'subject:try': 0.84; 'dennis': 0.91; 'received:108': 0.93
X-Injected-Via-Gmane http://gmane.org/
X-Gmane-NNTP-Posting-Host adsl-108-68-179-144.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21rc2
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:103315

Show key headers only | View raw


On Sun, 21 Feb 2016 21:42:18 +0530, Ganesh Pal <ganesh1pal@gmail.com>
declaimed the following:

>Hi Team,
>
>Iam on python 2.6 , need input on the below piece of code.
>
>
>EXIT_STATUS_ERROR=1
>
>def create_dataset():
>    """
>     """
>    logging.info("Dataset create.....Started !!!")
>    try:
>        if os.path.ismount("/nfs_mount"):
>            touch_file("inode_fixcrc.txt")
>            logging.info("Dataset create.....Done !!!")
>        else:
>            raise Exception("/nfs_mount is not mounted. Dataset create
>failed !!!")
>            return False

	The return will never be reached -- executing "raise" will result in an
immediate transfer to ...

>    except Exception as e:

... this exception handler...

>            logging.error(e)
>            sys.stderr.write("Dataset create failed...Exiting !!!")
>            sys.exit(EXIT_STATUS_ERROR)

... which forcibly exits the program.

>    return True

	As a result, this True is of no real use. If the function doesn't
succeed, the program kills itself; the only way a caller gets control back
is when the function succeeds, so there is no need to test for success.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


Thread

Re: can try expect have if else. Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-21 13:49 -0500

csiph-web