Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

input > input - Pg. 217

input The fileinput Module The fileinput module lets you loop over all the lines in a list of text files. Performance is quite good, comparable to the performance of direct iteration on each file, since fileinput uses internal buffering to minimize I/O. Therefore, you can use module fileinput for line-oriented file input whenever you find the module's rich function- ality convenient, without worrying about performance. The input function is the main function of module fileinput , and the module also provides a FileInput class that supports the same functionality as the module's functions. File and Text Oper- ations close close( ) Closes the whole sequence, so that iteration stops and no file remains open. FileInput class FileInput(files=None,inplace=0,backup='',bufsize=0) Creates and returns an instance f of class FileInput . Arguments are the same as for