readline in while loop
Geert Fannes
geert.fannes at esat.kuleuven.ac.be
Fri May 23 09:55:37 EDT 2003
i'm indeed a C++ programmer. then i have another question: suppose i
have 2 files and i want to read from both of them. things like this do
not work:
f1=file("file1","r");
f2=file("file2","r");
for line1 in f1 and line2 in f2:
print line1,line2;
any idea how i can solve this?
> Let me guess --- you are coming from C/C++?
>
> Python's idiom might be:
>
> f = file("test.txt", 'r')
> for line in f:
> print line
> f.close()
>
> hth,
> anton.
>
More information about the Python-list
mailing list