Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61791
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'string.': 0.05; 'subject:file': 0.07; 'subject:help': 0.08; 'line:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'shutil': 0.09; 'buffer,': 0.16; 'expecting': 0.16; 'prog': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:object': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; 'import': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'this:': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply- To:1': 0.27; 'unix': 0.29; 'getting': 0.31; "skip:' 10": 0.31; 'file': 0.32; 'actual': 0.34; 'copying': 0.34; 'subject:with': 0.35; 'objects': 0.35; 'christopher': 0.36; 'from:addr:live.com': 0.36; 'to:addr:python-list': 0.38; 'issue': 0.38; 'pm,': 0.38; 'moving': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'subject:Need': 0.64; 'containing': 0.69; 'actually,': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Christopher Welborn <cjwelborn@live.com> |
| Subject | Re: Need help with file object |
| Date | Thu, 12 Dec 2013 22:54:13 -0600 |
| References | <CACDG_KfbVuPbBpMWVcgVMQLjZ5N+mm-oPAaqyPoBKV62cW80hA@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 68-113-89-245.dhcp.leds.al.charter.com |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| In-Reply-To | <CACDG_KfbVuPbBpMWVcgVMQLjZ5N+mm-oPAaqyPoBKV62cW80hA@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4048.1386910472.18130.python-list@python.org> (permalink) |
| Lines | 35 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1386910472 news.xs4all.nl 2878 [2001:888:2000:d::a6]:37229 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:61791 |
Show key headers only | View raw
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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Need help with file object Christopher Welborn <cjwelborn@live.com> - 2013-12-12 22:54 -0600
csiph-web