[Edu-sig] Re: Teaching about files

Toby Donaldson tjd at sfu.ca
Wed Nov 10 00:17:59 CET 2004


>> So my question is, am I missing something here? Is f.read(n) 
>> important?

If you know you are only reading small files, then f.read() is great --- it
changes a file processing problem into a string processing problem.

The "for line in file:" idiom runs into problems if the file doesn't happen
to have '\n's in it. To be sure, you always need to limit the number of
bytes you read in.

Toby
--
Dr. Toby Donaldson
School of Computing Science (Surrey)
Simon Fraser University




More information about the Edu-sig mailing list