Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61791 > unrolled thread
| Started by | Christopher Welborn <cjwelborn@live.com> |
|---|---|
| First post | 2013-12-12 22:54 -0600 |
| Last post | 2013-12-12 22:54 -0600 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Need help with file object Christopher Welborn <cjwelborn@live.com> - 2013-12-12 22:54 -0600
| From | Christopher Welborn <cjwelborn@live.com> |
|---|---|
| Date | 2013-12-12 22:54 -0600 |
| Subject | Re: Need help with file object |
| Message-ID | <mailman.4048.1386910472.18130.python-list@python.org> |
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 Unicode: need sting or buffer, file found
>
> What that means and how I can resolve it.
>
> Regards,
> Dj
>
>
>
You are sending the actual file objects to shutil.move, it is expecting
a string. Actually, strings containing the path to move and the
destination. Like this: shutil.move('/tmp/file2', '/tmp/file1')
--
- Christopher Welborn <cjwelborn@live.com>
http://welbornprod.com
Back to top | Article view | comp.lang.python
csiph-web