Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61793
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit4.readnews.com!panix!gordon |
|---|---|
| From | John Gordon <gordon@panix.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Need help with file object |
| Date | Fri, 13 Dec 2013 05:37:01 +0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Lines | 29 |
| Message-ID | <l8e6ds$7kb$1@reader1.panix.com> (permalink) |
| References | <mailman.4047.1386908972.18130.python-list@python.org> |
| NNTP-Posting-Host | panix1.panix.com |
| X-Trace | reader1.panix.com 1386913021 7819 166.84.1.1 (13 Dec 2013 05:37:01 GMT) |
| X-Complaints-To | abuse@panix.com |
| NNTP-Posting-Date | Fri, 13 Dec 2013 05:37:01 +0000 (UTC) |
| User-Agent | nn/6.7.3 |
| Xref | csiph.com comp.lang.python:61793 |
Show key headers only | View raw
In <mailman.4047.1386908972.18130.python-list@python.org> Unix SA <d.joshi84@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
gordon@panix.com watch 'House', or a real serial killer to watch 'Dexter'.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Need help with file object Unix SA <d.joshi84@gmail.com> - 2013-12-13 09:59 +0530 Re: Need help with file object rusi <rustompmody@gmail.com> - 2013-12-12 20:53 -0800 Re: Need help with file object John Gordon <gordon@panix.com> - 2013-12-13 05:37 +0000
csiph-web