file.readlines() - gives me error (bad file descriptor)

Aldo Cortesi aldo at
Thu Jan 6 01:44:43 EST 2005

Thus spake wordsender at (wordsender at

> Hey guys,
> I can't figure this one out, why is this simple script giving me
> problems?
> logfile=file(r'test.txt','w')

You've opened the file in write mode. To read from the file,
you'll have to reopen it in read mode ("r"). 

Also, if the file you're dealing with really is a log file,
you probably want don't want to open it in write mode for
writing information either, since that will truncate the
file and lose previously logged information. Try append mode
("a") instead.



Aldo Cortesi
aldo at
Off: (02) 9283 1131
Mob: 0419 492 863

More information about the Python-list mailing list