File Object behavior
fatuheeva at yahoo.com
Wed Apr 4 00:52:43 CEST 2007
Bruno Desthuilliers wrote:
> Michael Castleton a écrit :
>> When I open a csv or txt file with:
>> infile = open(sys.argv,'rb').readlines()
>> infile = open(sys.argv,'rb').read()
>> and then look at the first few lines of the file there is a carriage
>> line feed at the end of each line - \r\n
> Is there any reason you open your text files in binary mode ?
> Unless you're using the csv module (which requires such a mode - but
> then you don't care since you're not working with the raw data
> yourself), you should consider opening your files in text mode. This
> should solve your problem (if not, then you have a problem with
> universal newlines support in your Python install).
No particular reason in this case. It was probably as a holdover from using
the csv module in the past. I'm wondering though if using binary on very
files (>100Mb) would save any processing time - no conversion to system
What do you think?
View this message in context: http://www.nabble.com/File-Object-behavior-tf3520070.html#a9827881
Sent from the Python - python-list mailing list archive at Nabble.com.
More information about the Python-list