My first ever Python program, comments welcome

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Jul 22 02:56:55 CEST 2012


On Sat, 21 Jul 2012 16:10:51 -0400, Dave Angel wrote:

>> with fileinput.input(files=(filename)) as f:
> 
> fileinput is much more general than you want for processing a single
> file.  That may be deliberate, if you're picturing somebody using
> wildcards on their input.  But if so, you should probably use a
> different name, something that indicates plural.

Also, fileinput is more a convenience module than a serious production 
quality tool. It works, it does the job, but it can be slow. From the 
source:

    Performance: this module is unfortunately one of the slower ways of
    processing large numbers of input lines.


-- 
Steven



More information about the Python-list mailing list