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

Gurpreet Sachdeva gurpreet.sachdeva at gmail.com
Thu Jan 6 04:15:24 EST 2005


On Thu, 6 Jan 2005 14:27:40 +0530, Binu K S <binux.lists at gmail.com> wrote:
> I'm sorry, I didn't get what you trying to say here. Where do you see
> a read altering the file? An example might help.

Please try:

logfile=file(r'test.txt','w+')
logfile.write('datetime')

Check the contents of test.txt, you will get what ever was required...

Now Run:

logfile=file(r'test.txt','w+')
logfile.write('datetime')
logfile.readlines()

and check the contents of test.txt???
My doubt is that logfile.write('datetime') will write datetime that is
universaly accepted but why all that junk is appending to that when I
add logfile.readlines()

Strange or Am I on drugs??? :o)

Please Comment...

Garry



More information about the Python-list mailing list