[Tutor] Making a python script to feed files into another python script

John Fouhy john at fouhy.net
Tue Sep 11 01:11:00 CEST 2007

On 11/09/2007, Ashley Booth <abooth at stanford.edu> wrote:
> I am trying to create a script that will get files from a directory
> that the user specifies, then feeds the relevant input and output
> (which are input and output paths) into another python script whose
> path is also given by the user. I'm pretty lazy after all and I would
> rather spend my time making tools than doing the busy-work myself.

Hi Ashley,

You've basically got two options:

1. You can build a command line and then use os.system to call it:
       script2 = raw_input('python script path:')
       input, output = # whatever
       os.system('python %s %s %s' % (script2, input, output))

2. You can import your second script and call its main function
directly.  How well this works will depend on the structure of the
second script.


More information about the Tutor mailing list