ok,,, my script writes a dictionary to a file.but i need only the values from the dictionary which should be sepearted by a comma,,,so i did as following: some=getAllData()------>dictionary f=open("test.txt", "w") for value in some.values(): f.writelines('\%s\,' % value )---->strings seperated by comma when i execute the above code,my test.txt file has the following: a,b,c,d, now i need to delete the comma at the end,,,this is my problem,,, kavitha Mikael Olofsson <[EMAIL PROTECTED]> wrote: kavitha thankaian wrote: > i get an error when i try to delete in file and rename it as out > file,,the error says > "permission denied".
Perhaps you should give us both the exact code you are running and the complete traceback of the error. That could make things easier. There can be numerous reasons for "permission denied". > actually i need something like following: > > in_file = open('in.txt','w') > for line in in_file: > line.strip().strip(',') > > but when i run the above code,i get an error"bad file descriptor" Of course you do! You are opening the file for writing, but your code attempts to read the file. Probably, you think that the code would change the lines in the file itself, which it does not, even if it would be possible to read from a file opened for writing. What's wrong with the code that Mohammad posted? Note that you might need to close out_file in his code. /MiO -- http://mail.python.org/mailman/listinfo/python-list --------------------------------- Heres a new way to find what you're looking for - Yahoo! Answers
-- http://mail.python.org/mailman/listinfo/python-list