Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Li Wang
> (my smtp mail server has been down for a few hours, so you have some other > responses.) > > yes, as far as I can tell from the docs, the 'b' flag doesn't matter in > Unix/Linux. Note that I haven't actually been on a Unix machine since > starting with Python, but it matches what else I know. A

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Li Wang
2009/5/8 : > On May 8, 5:08 am, Li Wang wrote: >> Hi Dave: >> Thank you very much for you explanation:) >> >> > Chances are you forgot the "b" parameter to open(). Unnecessary in Unix, >> > it >> > tells the library to *not* translate \r\n to \n upon read, or the inverse >> > on write. In ot

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Li Wang
2009/5/8 Scott David Daniels : > Li Wang wrote: >> >> So, if I am using python in Linux, do open('file', 'r') and >> open('file', 'rb') work the same way? > > You get identical results, but you ar lying to the reader of your code. > you should include the 'b' if what you want is bytes (or octets if

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Scott David Daniels
Li Wang wrote: So, if I am using python in Linux, do open('file', 'r') and open('file', 'rb') work the same way? You get identical results, but you ar lying to the reader of your code. you should include the 'b' if what you want is bytes (or octets if you prefer), and not use it if what you exp

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread pruebauno
On May 8, 5:08 am, Li Wang wrote: > Hi  Dave: > Thank you very much for you explanation:) > > > Chances are you forgot the "b" parameter to open().  Unnecessary in Unix, it > > tells the library to *not* translate \r\n  to \n upon read, or the inverse > > on write.  In other words, with the "b" pa

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Li Wang
Hi Dave: Thank you very much for you explanation:) > Chances are you forgot the "b" parameter to open(). Unnecessary in Unix, it > tells the library to *not* translate \r\n to \n upon read, or the inverse > on write. In other words, with the "b" parameter, the file is read in > unchanged. So

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Li Wang
Hi: Problem solved Thank you very much, it works, It is my own problem:) All the best, Li 2009/5/8 Li Wang : > 2009/5/8 Chris Rebert : >> On Thu, May 7, 2009 at 10:04 PM, Li Wang wrote: >>> Hi all: >>> > >> the file, e.g. open("the_file.xls", "rb") >> Unlike *nix, Windows differentiates betwee

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Li Wang
2009/5/8 Chris Rebert : > On Thu, May 7, 2009 at 10:04 PM, Li Wang wrote: >> Hi all: >> > the file, e.g. open("the_file.xls", "rb") > Unlike *nix, Windows differentiates between binary and text files, > hence the need for the "b" flag to specify which you're dealing with. Hi Thank you very much

Re: Python 2.6, File read() problems in Windows Xp

2009-05-08 Thread Dave Angel
Li Wang wrote: Hi all: I am trying to read a non-text file as a string by using Python read(), however, it seems there is some thing wrong with it. I can use read() on text file correctly, but unable to read .xls file correctly. (The program can read any file correctly in Fedora 10) Any idea ho

Re: Python 2.6, File read() problems in Windows Xp

2009-05-07 Thread Chris Rebert
On Thu, May 7, 2009 at 10:04 PM, Li Wang wrote: > Hi all: > > I am trying to read a non-text file as a string by using Python > read(), however, it seems there is some thing wrong with it. I can use > read() on text file correctly, but unable to read .xls file correctly. > (The program can read an

Python 2.6, File read() problems in Windows Xp

2009-05-07 Thread Li Wang
Hi all: I am trying to read a non-text file as a string by using Python read(), however, it seems there is some thing wrong with it. I can use read() on text file correctly, but unable to read .xls file correctly. (The program can read any file correctly in Fedora 10) Any idea how to solve this p