Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ganesh Pal Newsgroups: comp.lang.python Subject: how to make the below code look better Date: Wed, 2 Dec 2015 17:41:21 +0530 Lines: 32 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de OR/62O6O3AvS6c+vhvZUmgkPSWuS5/VWmvK5ukVM4ECw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'executed': 0.07; 'subject:code': 0.07; 'exception,': 0.09; 'python': 0.10; '2.7': 0.13; 'failed")': 0.16; 'messy': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:make': 0.16; 'try:': 0.18; 'team,': 0.18; 'to:name:python-list@python.org': 0.20; 'assuming': 0.22; 'linux': 0.26; 'question': 0.27; 'message- id:@mail.gmail.com': 0.27; 'code': 0.30; 'statement': 0.32; 'except': 0.34; 'received:google.com': 0.35; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'suggestion': 0.37; 'skip:v 20': 0.38; 'received:209': 0.38; 'skip:o 20': 0.38; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'within': 0.64; 'backup': 0.66; 'subject:below': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=t8dU3JBsWG/YgGoovVf+GXUn3W+iCyAbNGzt0gEvyNk=; b=VYs30e15JdhjQKjYBNIpA5J1Gu0IB6iSI4BdqnDiJUtnr18/8IfjJYmev7qGYQC6Aq CmTTnE4Uho3mHZx56M9fnfDMlEsYlEYL0kJMbSJTXPPrB/wkuMF3uYwXoNToczrdvux1 p119d1hyYhr7ipJ04eDj+7mG98Mx85nZLVvuvF46/Zfz01aL82wmPbBQaBFcPfAkKPvr /0OO2P60fwqiCvu9Vwu9t9bP+FLR+D0caHgmgDG+H46wm3IHNn70UfLLojdPtU9UHqjN UBpHw7CXR/CFvCF3dW4elPXzH05vKntoPufZle5W+YbiC1VphR3L1NbvgKwtL5H+Q0kk Y5Ew== X-Received: by 10.25.147.84 with SMTP id v81mr2355855lfd.119.1449058281814; Wed, 02 Dec 2015 04:11:21 -0800 (PST) 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:99872 Hello team, I need suggestion to improve the below code , Iam on Linux and python 2.7 if not os.path.ismount("/tmp"): sys.exit("/tmp not mounted.") else: if create_dataset() and check_permission(): try: run_full_back_up() run_partial_back_up() except Exception, e: logging.error(e) sys.exit("Running backup failed") if not validation_errors(): sys.exit("Validation failed") else: try: compare_results() except Exception, e: logging.error(e) sys.exit("Comparing result failed") Question 1: 1. if create_dataset() and check_permission(): Iam assuming that if statement will be executed only if both the functions are true ? 2. Can I have a if statement within if else ? , some how I feel its messy 3. Any other suggestion ? please