Re: how to make the below code look better

2015-12-02 Thread Chris Angelico
On Thu, Dec 3, 2015 at 5:20 PM, Ganesh Pal wrote: >> The first suggestion I'd make is to avoid the comma syntax for >> exception handling. Replace "except Exception, e:" with "except >> Exception as e:". That's a trivial change of syntax that shouldn't >> affect your code at all; consider it low-h

Re: how to make the below code look better

2015-12-02 Thread Ganesh Pal
On Wed, Dec 2, 2015 at 6:00 PM, Chris Angelico wrote: > If both the functions return true values, yes. You have an indentation > error there, but I'm assuming you meant to have the try/except > indented further. > Correct I had meant to have try/except indented further. >> 2. Can I have a if sta

Re: how to make the below code look better

2015-12-02 Thread me
On 2015-12-02, 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.er

Re: how to make the below code look better

2015-12-02 Thread Chris Angelico
On Thu, Dec 3, 2015 at 12:28 AM, Steven D'Aprano wrote: >> if not os.path.ismount("/tmp"): >>sys.exit("/tmp not mounted.") > > This is good enough for quick and dirty scripts, but this is vulnerable to a > race condition. It may be that /tmp is mounted *now*, but a millisecond > later

Re: how to make the below code look better

2015-12-02 Thread Steven D'Aprano
On Wed, 2 Dec 2015 11:11 pm, Ganesh Pal wrote: > 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.") This is good enough for quick and dirty scripts, but this is vulnerable to a

Re: how to make the below code look better

2015-12-02 Thread Chris Angelico
On Wed, Dec 2, 2015 at 11:20 PM, BartC wrote: > You could make the indentation more consistent. Example: You fixed one indentation error... > if create_dataset() and check_permission(): > try: > run_full_back_up() > run_partial_back_up() > except Excep

Re: how to make the below code look better

2015-12-02 Thread Chris Angelico
On Wed, Dec 2, 2015 at 11:11 PM, Ganesh Pal wrote: > 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

Re: how to make the below code look better

2015-12-02 Thread BartC
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