Question re: strings / f.read() and eof()

Rob Mitchell r_mitchell at telus.net
Thu May 20 17:43:30 EDT 2004


Hi;

 

I am trying read a file that has hex data, unfortunately some of that data
is a \x1A.

 

Both f.read() and string[x:y] return a truncated srting once this value is
encounered.  Obviously this is net the desired behaviour.  What can I do to
get this working?

 

The - in the f.read does read all of the file. that works, but how do I get
around the truncation that occurs in the line :

log = str[i*62:(i+1)*62]  

Normally this returns a string of len() = 62, but when the \x1A is
encountered, it is truncated to 14.

 

Hope someone can help.

 

Rob.

r_mitchell at telus.net

 

 

<code snippet>

 

load.AddLog( f.read(-62), load.logs )

 

 

            def AddLog(self, str, count):

                        print count

                        for i in range( count ):

                                    log = str[i*62:(i+1)*62]

                                    self.details.append( loadDetailGLS( log
) )

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20040520/0feef8fd/attachment.html>


More information about the Python-list mailing list