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


Groups > comp.lang.python > #99872

how to make the below code look better

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ganesh Pal <ganesh1pal@gmail.com>
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 <mailman.120.1449058284.14615.python-list@python.org> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de OR/62O6O3AvS6c+vhvZUmgkPSWuS5/VWmvK5ukVM4ECw==
Return-Path <ganesh1pal@gmail.com>
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 <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:99872

Show key headers only | View raw


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

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


Thread

how to make the below code look better Ganesh Pal <ganesh1pal@gmail.com> - 2015-12-02 17:41 +0530
  Re: how to make the below code look better BartC <bc@freeuk.com> - 2015-12-02 12:20 +0000
    Re: how to make the below code look better Chris Angelico <rosuav@gmail.com> - 2015-12-02 23:31 +1100
  Re: how to make the below code look better Steven D'Aprano <steve@pearwood.info> - 2015-12-03 00:28 +1100
    Re: how to make the below code look better Chris Angelico <rosuav@gmail.com> - 2015-12-03 00:49 +1100
  Re: how to make the below code look better me <self@example.org> - 2015-12-02 15:23 +0000

csiph-web