Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

This is the continuation of my previous question where it was not that clear what I want to do. Now please find the Full code here I know this code is very crude as I am new to programming . I am sure this code can be written in another way more optimally but I am not that experienced. Now my question is I will be running this code from Python shell.

while 1 ==1:
    execfile('adhocTest.py')

This code consists of two parts 1. Prerequisite 2. Main program.

The prerequisite is to copy a template Excel file and paste in a directory. Main program is to do some operation and result should be written onto this file and validate few cells. If the condition is true main program will keep continuing else I want that whole script should run again i.e Run pre requisite as well as main program. I am stuc at this point as of now if teh condition is false it exits the whole script.

As I said this code is crude if anyone helps me to optimize it I will be very happy. But this is secondary. I need the continuous run of this script when the condition is false.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
610 views
Welcome To Ask or Share your Answers For Others

1 Answer

You need to re-structure your program:

def call_me():
    while True:
        prerequisite()
        main_operations()
        if validate():
            main_continuing()

or

def call_me():
    while True:
        prerequisite()
        while validation():
            main_operations()

This will loop around as you need it to.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...