[Python-bugs-list] [ python-Bugs-768698 ] Odd behavior in the file object
SourceForge.net
noreply@sourceforge.net
Wed, 09 Jul 2003 13:05:17 -0700
Bugs item #768698, was opened at 2003-07-09 20:05
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=768698&group_id=5470
Category: Python Library
Group: Python 2.2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: David Nemeth (davidnemeth)
Assigned to: Nobody/Anonymous (nobody)
Summary: Odd behavior in the file object
Initial Comment:
Hello,
I was using
Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit
(Intel)] on win32
to write a file to parse a text file. The file was
divided in two parts, so I wrote something like this:
file = open("foobar" ,"r")
for line in file:
#read a few lines
break
for line in file:
read rest of lines
A chunk of the middle part of the file ends up missing.
Oddly, it's not the section just after the first few
lines are read.
I've attached an example script and data file which
shows this problem on my system (Windows 2000).
The workaround I'm using (which works) is :
file = open("foobar","r")
while 1:
line = file.readline()
if line is what I want:
break
for line in file:
do stuff
Which seems to work
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=768698&group_id=5470