![]() |
Python .append problem -- help needed
So I'm working on a fairly simple python script, but have run into a problem.
I'm trying to append data to a file, but the .append object doesn't work (.write does, though): Code:
Traceback (most recent call last): Code:
logfile = open(date_stamp, 'w') Any idea what is wrong? |
Re: Python .append problem -- help needed
You should consult the python library reference.
file objects doesn't have the append method, only mutable secuence types (like lists) have .append On files, you can open the file for appending, so writes get appended to the end of the file. Do not confuse the file on disk with a file object. |
Re: Python .append problem -- help needed
Thanks. Yep, I read that somewhere, too. The "Dive into Python" text was a little confusing. I confuse easily :o
|
Re: Python .append problem -- help needed
Dive into Python is excellent work but really confusing stuff. :)
You can use mode "a" to append: Code:
fd = open("myfile", "a") |
Re: Python .append problem -- help needed
Quote:
Oh, and I'm glad someone else thinks Dive into Python is confusing :o |
All times are GMT. The time now is 21:11. |
vBulletin® Version 3.8.8