fileinput module doesn't work to spec?

Dale Strickland-Clark dale at out-think.NOSPAMco.uk
Tue Oct 24 15:00:28 EDT 2000


Thanks to all who replied.

I understand how the redirection works now but what happens if you
need to write out the last line read? Is the redirection still around?

Also, I had misread the bit about the backup file.

Cheers.

Carel Fellinger <cfelling at iae.nl> wrote:

>Dale Strickland-Clark <dale at out-think.nospamco.uk> wrote:
>> According to the spec, the fileinput module should support overwriting
>
>the specs are *always* right:), but keep a lot implicit:)
>
>
>> table = []
>> for line in fileinput.input(sys.argv[1:], inplace = 1):
>> 	table = table + genRow(line)
>
>printing in this loop will go to the file currently read
>
>> print ''.join(table)
>
>printing after the loop will again go to standard output.

Dale Strickland-Clark
Out-Think Ltd
Business Technology Consultants





More information about the Python-list mailing list