If statement with or operator

Ganesh Pal ganesh1pal at gmail.com
Wed Feb 22 12:03:31 EST 2017


Hello Friends,

I  need suggestion on the if statement in the below code  , all that I was
trying to do was to add a check  i.e if any one of the functions return
True then  break the loop.


 end_time = time.time() + 300
    umount_completed = False
    while time.time() < end_time:
        if attempt_umount() is True or df_output_lines() is True:
           logging.info("umount completed sucessfully")
           umount_completed = True
           break
        time.sleep(15)
    assert umount_completed, "ERROR: The umount failed Exiting"

Can this be optimized better  , please suggest.  I am on Linux and Python
2.7


Regards.
Ganesh



More information about the Python-list mailing list