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


Groups > comp.lang.python > #99873

Re: how to make the below code look better

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From BartC <bc@freeuk.com>
Newsgroups comp.lang.python
Subject Re: how to make the below code look better
Date Wed, 2 Dec 2015 12:20:15 +0000
Organization A noiseless patient Spider
Lines 49
Message-ID <n3mnhi$ce5$1@dont-email.me> (permalink)
References <mailman.120.1449058284.14615.python-list@python.org>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Wed, 2 Dec 2015 12:17:55 -0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="cf45b3961a050227b1103bebc3cbc15a"; logging-data="12741"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196an4UElzXLZ3GfZCZ0EFz"
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0
In-Reply-To <mailman.120.1449058284.14615.python-list@python.org>
Cancel-Lock sha1:Q5tth6aWh5/PKdtnCZp6RFqblng=
Xref csiph.com comp.lang.python:99873

Show key headers only | View raw


On 02/12/2015 12:11, Ganesh Pal wrote:

> 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")

> 3.  Any other suggestion ? please


You could make the indentation more consistent. Example:

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")



-- 
Bartc

Back to comp.lang.python | Previous | NextPrevious in thread | Next 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