Python commands in an interpreted script

Terry Reedy tjreedy at home.com
Thu Jan 24 09:49:14 EST 2002


"Heiko Wolf" <heiko.wolf at dlr.de> wrote in message
news:d013da35.0201240218.2a199df at posting.google.com...
> Hi,
>
> I've got a python program here that reads out from script like
>
> key_word1
> key_word2
>
> and interprets the keywords, e.g. if keyword1 is read funtion1 is
> started. Now I want to use Python funtionality in that script, e.g.
a
> loop like
>
> for i in range(10):
>   keyword1
>
> if I want keyword1 to be interpreted 10 times.
> Is there a way that Python executes commands, but just interprets
> certain strings?

No.  You will have to write the script something like

for i in range(10):
  i(keyword1)

and then rewrite program like

def i(keword):
   #your current interpreter program

execfile(script)

or better, put

from interpreter import i

at the top of the script.

Terry J. Reedy







More information about the Python-list mailing list