Skip to Content
Python: Essential Reference, Third Edition
book

Python: Essential Reference, Third Edition

by David Beazley
February 2006
Intermediate to advanced content levelIntermediate to advanced
648 pages
14h 53m
English
Sams
Content preview from Python: Essential Reference, Third Edition

fileinput

The fileinput module iterates over a list of input files and reads their contents line by line. The main interface to the module is the following function:


input([files [, inplace [, backup]]])

Creates an instance of the FileInput class. files is an optional list of filenames to be read (a single filename is also permitted). If omitted, the filenames are read from the command line in sys.argv[1:]. An empty list implies input from stdin, as does a filename of '-'. If inplace is set to True, each input file is moved to a backup file and sys.stdout is redirected to overwrite the original input file. The backup file is then removed when the output is closed. The backup option specifies a filename extension such as .bak that is appended ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python: Essential Reference

Python: Essential Reference

David M. Beazley

Publisher Resources

ISBN: 0672328623Purchase book