create a tmp file for system execution

Eric Texier erict at millfilm.co.uk
Wed May 29 10:34:57 EDT 2002


I have a py script executing a bunch of os.system in a loop.
It is not very fast and I was wondering if it will not be better
to recreate a execution file.

My 2 questions:

1) what is faster for a big number of call

for i in range(1,2000):
    os.system("ls  F1.%d   F2.%d" % ( i , i ) "  )

OR

fileOut = open("tmpFile",w)
for i in range(1,2000):
    fileOut.write("ls  F1.%d   F2.%d" % ( i , i ) " )

fileOut.close()
os.system("csh -c 'source tmpFile' ")
os.system("rm -f tmpFile")


2) if the second one is better I would like to kwo if there is any thing

in python for temporary file, the drag being to if you do not come for
a specific naming mechanism, you file can be change by and other
process before it execute






More information about the Python-list mailing list