Newbie question regarding .readline()
jim roush
jar at mminternet.com
Sun Jul 30 00:33:29 EDT 2000
I have the following snippet of code causing me problems
def process_free_category(cat_title, filename, start_anchor_tag):
PK_INFILE = open(filename, 'r')
PKFRESHOUT.write('<br><b>' + cat_title + '</b><br><br>\n')
# Find beginning of section
for line in PK_INFILE.readline():
print line
if string.find(line, start_anchor_tag) > -1:
break
print line
the problem is, line is only one character instead of an entire line.
I used those print statements to verify this. It's as if I used
.read() instead. If I use .readlines() instead, it reads multiple
lines like it should.
What gives?
jar at mminternet.com
James A Roush
More information about the Python-list
mailing list