In <mailman.4047.1386908972.18130.python-l...@python.org> Unix SA 
<d.josh...@gmail.com> 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 and how I can resolve it.

shutil.move() expects filename arguments, not open file objects.

Also, since your open() statements are missing the file mode ('r' or 'w'),
they will both open in the default read mode.

Also, it really helps if you post the real code and real error message.
Don't type them from memory.

-- 
John Gordon         Imagine what it must be like for a real medical doctor to
gor...@panix.com    watch 'House', or a real serial killer to watch 'Dexter'.

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to