0

I want to read a textfile in which a python script is saved. Is it possible to run this script line by line with the subprocess module?

My prefabricated code-snippet:

def Call_LSD(session,worknumber="",projectnumber=""):
    textfile=open('script.txt', 'r')
    Lines=textfile.readlines()
    
    for line in Lines:

        "Here should be the process, where each line has to be executed!"    

        if.....:


    textfile.close()
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
StiloOS
  • 1
  • 2
  • Why don't you just make it .py and import it? What are you actually trying to achieve here? – jonrsharpe Nov 10 '20 at 20:45
  • @jonrsharpe, or `.bat`/`.sh` – Olvin Roght Nov 10 '20 at 20:45
  • 1
    @OlvinRoght the OP said it's a Python script, it's [more work](https://stackoverflow.com/questions/2601047/import-a-python-module-without-the-py-extension) with other extensions. – jonrsharpe Nov 10 '20 at 20:51
  • As in my code, after each line when it‘s executed there should be a conditional statement. In this statement run some other code after that the next line of the script shall continue. – StiloOS Nov 10 '20 at 22:11

0 Answers0