newbie: another problem with file reading
Flavian Hardcastle
deathtospam43423 at altavista.com
Sat Feb 23 03:07:10 EST 2002
In this instance, _before_ = 8221 , _after_ = 8305.
What this function should do, is read only up to position 8221 in _chat_,
print a .gif, then read the rest of the _chat_ file. Why isn't it doing
that?
def get_posts(num, before):
index = map(string.rstrip, open(chat_index).readlines())
after = int(str(index[-1]))
g = int(str(index[-(num+1)])) #for some reason, need to add +1
#maybe cuz of the way chat_log and
#chat_index are set up
print int(before)
chat = open(chat_log, 'r')
chat.seek(g) #seek to where the post the user wants is
print chat.read(before) #should mean read up to previous position
print "<img src = pointer.gif></br>"
print chat.read() #read rest of file.
print after
--
"You can tell whether a man is clever by his answers. You can tell whether
a man is wise by his questions." Naguib Mahfouz
netvegetable at dingoblue.net.au
More information about the Python-list
mailing list