Re: Need help with file object

2013-12-13 Thread bob gailer
On 12/12/2013 11:29 PM, Unix SA wrote: ... With above prog I am getting error TypeError: coercing to Unicode: need sting or buffer, file found In future please copy and paste the entire traceback. It appears that you typed in just one line of it. In this case the line raising the exception w

Re: Need help with file object

2013-12-12 Thread John Gordon
In Unix SA writes: > f=open('/tmp/file1') > s=open('/tmp/file2') > for line in f: > if 'match' not in line: > s.write(line) > import shutil > shutil.move(s, f) > With above prog I am getting error > TypeError: coercing to Unicode: need sting or buffer, file found > What that means an

Re: Need help with file object

2013-12-12 Thread rusi
On Friday, December 13, 2013 9:59:25 AM UTC+5:30, Unix SA wrote: > s=open('/tmp/file2') >s.write(line) Among other things you are missing a write mode (2nd optional argument to open) http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files -- https://mail.python.org/

Re: Need help with file object

2013-12-12 Thread Christopher Welborn
On 12/12/2013 10:29 PM, Unix SA wrote: Hello, I am facing some issue when copying or moving file f=open('/tmp/file1') s=open('/tmp/file2') for line in f: if 'match' not in line: s.write(line) import shutil shutil.move(s, f) With above prog I am getting error TypeError: coercing to U

Need help with file object

2013-12-12 Thread Unix SA
Hello, I am facing some issue when copying or moving file f=open('/tmp/file1') s=open('/tmp/file2') for line in f: if 'match' not in line: s.write(line) import shutil shutil.move(s, f) With above prog I am getting error TypeError: coercing to Unicode: need sting or buffer, file found W