Fileinput as a generator

Category: Python - Miscellaneous

This script provides a class called LineIterator that iterates over every line in a list of files, performing the basic functionality as fileinput module in the standard library (which mimics Perl's operator). Basically acts as a simple and methodical way to iterate over every line in a list of files. If no files are specified at instance creation, then sys.argv[1:] is used. If that is empty, then sys.stdin is used.sys.stdin can be specified in the list of files by listing '-' as a file.Lacking functionality, compared to the fileinput module, is in-place editing and subsequently backup. The module functions that are included in fileinput are left out here for space concerns. readline() has also been left out since the generator can just have its .next() method called. the gene; Date: 24 May, 2012


List Iterator - Files List - Files Manipulation - List - Iterator - Files

Homepage: http://code.activestate.com/

Developer: code.activestate.com

License: Freeware

Operating System: All

Add a Comment

all are required fields

     
What do you think of this resource?

Select Your Rate:

Votes:0

 

Related Scripts Download

The basic iterator for a list doesn't allow one to skip forward (except with "continue"), or backward (at all), nor does it behave well if the list is modified while it is being traversed.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


The basic iterator for a list doesn't allow one to skip forward (except with "continue"), or backward (at all), nor does it behave well if the list is modified while it is being traversed.

developer Developer: code.activestate.com
license License: Artistic License, GNU General Public License (GPL)
operating systems Operating System: Windows, Linux, Mac OS, BSD, Solaris


This utility searches all the paths in a semi-colon delimited environment variable list for files matching a given filespec.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


This function walks a directory tree starting at a specified root folder, and returns a list of all of the files (and optionally folders) that match our pattern(s).

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


This recipe allows you to update desired files in a directory tree.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


If the 'file' object looks for a '.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All


Barcode designer software is affordable tool which is suitable for all size of organizations and allow printing of multidimensional barcode.

developer Developer: Professional Barcode
license License: GNU General Public License (GPL)
operating systems Operating System: Not Available


The Download Tracker is a CGI script that manages the downloads from your web page.

developer Developer: widexl.com
license License: Freeware
operating systems Operating System: All


This script opens a key in Win32 registry base like a file.

developer Developer: code.activestate.com
license License: Freeware
operating systems Operating System: All