0

I have a basic question. I would like to make running Arc.py several times with different input (R0.arg)and output (V0.art) The idea is to repeat the command like this:

Arc.py R0.arg V0.art

Arc.py R1.arg V1.art

Arc.py R2.arg V2.art

Arc.py R3.arg V3.art

Arc.py R4.arg V4.art

Arc.py R#.arg V#.art

...

..

.

until #=1000.

Could you help me, please?

1
  • 2
    What are you using to run it? Commented Jun 28, 2012 at 14:39

1 Answer 1

2

Is there anything stopping you from doing the following?:

import whatever

def main(arg1):
    # routine to be run

if __name__=='__main__':
    sys.exit(main(sys.argv[1]))

In the other python file, just import the module and call the routine in a loop:

import otherfile

for i in xrange(1000):
    otherfile.main(arg1)
Sign up to request clarification or add additional context in comments.

5 Comments

Thank you for the reply, however I tried the first method, but it doesnt work. Could you detail a bit more, please?
You create two python files. One contains the routine that you want to run. The other file calls that routine in a loop with given arguments. I'm not too sure how else to explain that :-/ What do you mean you tried the first method? You should implement both blocks of code above (tailored to your needs, of course), not just the first. Sorry if I'm misunderstanding.
Because I am just not expert in Python. that s why I asked to tailored to my example ;) Thank you anyway
All you have to do is place your code in the main() method and fix the imports and add a way to change the arguments. I'm no Python expert by any means either, just takes a little patience.
You should use xrange instead of range, assuming Python 2.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.