readfile

Reading two text files line by line simultaneously

Reading two text files line by line simultaneously Question: I have two text files in two different languages and they are aligned line by line. I.e. the first line in textfile1 corresponds to the first line in textfile2, and so on and so forth. Is there a way to read both file line-by-line simultaneously? Below …

Total answers: 4

open read and close a file in 1 line of code

open read and close a file in 1 line of code Question: Now I use: pageHeadSectionFile = open(‘pagehead.section.htm’,’r’) output = pageHeadSectionFile.read() pageHeadSectionFile.close() But to make the code look better, I can do: output = open(‘pagehead.section.htm’,’r’).read() When using the above syntax, how do I close the file to free up system resources? Asked By: 1qazxsw2 || …

Total answers: 11

What's the correct way to use win32file.ReadFile to get the output from a pipe?

What's the correct way to use win32file.ReadFile to get the output from a pipe? Question: I’m using the pywin32 extensions to access the win32 API under Python. I’m new at doing Windows programming in Python — I’m a POSIX guy — so I may be doing things in a bone-headed manner. I’m trying to use …

Total answers: 3