basic output question

John Deas john.deas at gmail.com
Fri Jan 25 17:45:01 EST 2008


Hi, I am very new to Python (1 evening...)
I need to process a series of files (toto-1.txt toto-2.txt toto-3.txt
toto-4.txt), and as such I created a small program to go through the
files in a directory. I want to call the script with arguments, like

python script.py toto- 1 1 4

my script is as follow :

import sys
sys.argv
header=     sys.argv[1]
start =eval(sys.argv[2])
step  =eval(sys.argv[3])
nbit  =eval(sys.argv[4])

for i in range(nbit):
	filename=header+str(start+i*step)+'.txt'
	f=open(filename,'r')
	f.read()
	f.close()

My problem is that f.read() outputs nothing, and should I print
filename, I can check that they are well formed, and the files sits in
the same directory as my script.

Anyone could help me on this ?



More information about the Python-list mailing list