Hello all, I'm having a problem reading line-at-a-time from a file in Python. Basically, I've got some code like this:
Code:
while not self.commentStartRegex.search(line):
print ("# %06d > " % self.handle.tell()) + line[:80].rstrip()
time.sleep(1)
line = self.handle.readline()
Where self.commentStartRegex = re.compile(r'^\s*/\*\*'), and which is parsing some input code:
Code:
final ArrayList<Method> methods = Something.getInstance().lookupSomething(someClass, function);
if(null == methods || methods.size() == 0)
throw new NotImplementedException(someClass.toString() + " does not implement the function: " + function);
return methods;
}
/**
* This is a comment.
When I run it I get something more or less like this:
Code:
# 004367 > final ArrayList<Method> methods = Something.getInstance().lookupSomething(someCl
# 004412 > if(null == methods || methods.size() == 0)
# 004521 > throw new NotImplementedException(someClass.toString() + " does not implemen
# 004539 > return methods;
# 004542 > }
# 004543 >
# 013261 >
# 013261 >
... [keeps going ad infinitum]
So it seems that this code is somehow jumping to the end of the file. I don't understand why that is. Plus, there's nothing odd in the file, just printing characters, tabs, and Unix newlines. Does anybody have any ideas why this could be happening?