[Tutor] Syntax for Simplest Way to Execute One Python Program Over1000's of Datasets

Alan Gauld alan.gauld at btinternet.com
Fri Jun 10 01:53:11 CEST 2011


"B G" <compbiocancerresearcher at gmail.com> wrote

> I'm trying to analyze thousands of different cancer datasets and run 
> the
> same python program on them.  I use Windows XP, Python 2.7 and the 
> IDLE
> interpreter.


First thing: Don;t use IODLE as your interpreter. IDLE is a
development environment that should not be used for running
code in "production" type environments. Python is the interoreter,
use it directly.

> I already have the input files in a directory and I want to
> learn the syntax for the quickest way to execute the program over 
> all these
> datasets.

If the script take a filename as an input parameter you can likely do

python myfile.py *.*

from the OS command prompt.

Or in MacOS or Windows select all the files in Explorer and drag them 
onto
your script. I suspect most Linux desktops will allow the same.

Or you could write a second python script that traverses the files in 
your
folder and calls a function which contains your code (recall that a 
python
file can be impoerted as a module into another python file...)

Just some ideas,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list