readline in while loop

Andrew Koenig ark at research.att.com
Fri May 23 10:29:07 EDT 2003


Geert> i'm indeed a C++ programmer. then i have another question: suppose i
Geert> have 2 files and i want to read from both of them. things like this do
Geert> not work:

Geert> f1=file("file1","r");
Geert> f2=file("file2","r");
Geert> for line1 in f1 and line2 in f2:
Geert> 	print line1,line2;

Geert> any idea how i can solve this?

If you give a complete description of the behavior you want,
I'm sure it won't be hard to write a program that behaves that way.

For example, what should the program do if the two files have
different numbers of lines?

-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark




More information about the Python-list mailing list