Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #59107
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <joel.goldstick@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.065 |
| X-Spam-Evidence | '*H*': 0.87; '*S*': 0.00; 'exists.': 0.07; 'great.': 0.07; 'cc:addr:python-list': 0.11; 'def': 0.12; "'w')": 0.16; 'desktop?': 0.16; 'script,': 0.16; 'specifying': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'skip:" 20': 0.27; 'header:In- Reply-To:1': 0.27; 'tried': 0.27; 'said,': 0.30; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; "skip:' 10": 0.31; 'file': 0.32; 'url:python': 0.33; 'maybe': 0.34; "can't": 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'being': 0.38; 'skip:o 20': 0.38; 'nov': 0.38; 'pm,': 0.38; 'rather': 0.38; 'that,': 0.38; 'sure': 0.39; 'url:mail': 0.40; 'future': 0.60; 'solve': 0.60; 'skip:o 30': 0.61; 'complete': 0.62; 'such': 0.63; 'to:addr:gmail.com': 0.65; 'cut': 0.74; 'directory:': 0.84; 'joel': 0.91; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=fg6QE5p1a7kAGtNVpMkq2YSHuCnsej9oYi/uckhqYhk=; b=A5KWBi4KQ60YCsYzqerhnyofiwBu0RlqM4UJC8zUilsSo2vfmRurgOKmPAQZla6qaC RzjVvirQBO2xyC7eiZnOwBycrlKcS4QDtH8driAYNCmn5f7y2Qno/CAN7MmLYod3xvTp Fo+/qy11mfc9ZSA/SyOM1wOcu/ZWJdCMJdo3Ibx1VuCwT7JVg1Cuvpv5qwuBjKqR/5lQ VD5QULN81d1ixg6xGnk4SD5xqFXXm5+Dbv0p8Tp4PdWACOcKHh5nEgi3suAoR/HUoDrW pJoIJnMPmJZQ0iOn0HEEw99bojTPhJSVLISrzAvdbULXDhK4PLtbSeHhtDRHEmGQAVWf wAMw== |
| MIME-Version | 1.0 |
| X-Received | by 10.221.40.10 with SMTP id to10mr5237682vcb.22.1384209415889; Mon, 11 Nov 2013 14:36:55 -0800 (PST) |
| In-Reply-To | <521ed3d4-e2f7-4196-947d-61f94573a8ce@googlegroups.com> |
| References | <521ed3d4-e2f7-4196-947d-61f94573a8ce@googlegroups.com> |
| Date | Mon, 11 Nov 2013 17:36:55 -0500 |
| Subject | Re: Creating a function for a directory |
| From | Joel Goldstick <joel.goldstick@gmail.com> |
| To | Matt <mattgraves7@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | "python-list@python.org" <python-list@python.org> |
| 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.2403.1384209418.18130.python-list@python.org> (permalink) |
| Lines | 30 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1384209418 news.xs4all.nl 15959 [2001:888:2000:d::a6]:47697 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:59107 |
Show key headers only | View raw
On Mon, Nov 11, 2013 at 5:26 PM, Matt <mattgraves7@gmail.com> wrote:
> So I want to take the file, "desktop/test.txt" and write it to "desktop/newfolder/test.txt". I tried the below script, and it gave me: "IOError: [Errno 2] No such file or directory: 'desktop/%s.txt'". Any suggestions would be great.
Its better in the future to cut and paste the traceback rather than
paraphrase...
That being said, it can't find the in_file. Maybe you aren't in the
directory above desktop? Try specifying a complete path, instead of
relative. Once you solve that, be sure the ouput path is specificed
completely and that it exists.
>
>
>
> def firstdev(file):
> in_file = open("desktop/%s.txt") % file
> indata = in_file.read()
> out_file = open("desktop/newfolder/%s.txt", 'w') % file
> out_file.write(indata)
> out_file.close()
> in_file.close()
>
> firstdev("test")
> --
> https://mail.python.org/mailman/listinfo/python-list
--
Joel Goldstick
http://joelgoldstick.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Creating a function for a directory Matt <mattgraves7@gmail.com> - 2013-11-11 14:26 -0800
Re: Creating a function for a directory Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-11 17:36 -0500
Re: Creating a function for a directory Chris Angelico <rosuav@gmail.com> - 2013-11-12 09:38 +1100
Re: Creating a function for a directory bob gailer <bgailer@gmail.com> - 2013-11-11 17:42 -0500
Re: Creating a function for a directory Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-11 17:44 -0500
Re: Creating a function for a directory Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-11-11 22:45 +0000
Re: Creating a function for a directory Rick Johnson <rantingrickjohnson@gmail.com> - 2013-11-11 14:51 -0800
Re: Creating a function for a directory Chris Angelico <rosuav@gmail.com> - 2013-11-12 10:11 +1100
Re: Creating a function for a directory Rick Johnson <rantingrickjohnson@gmail.com> - 2013-11-11 21:42 -0800
Re: Creating a function for a directory Chris Angelico <rosuav@gmail.com> - 2013-11-12 17:02 +1100
Re: Creating a function for a directory Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-12 00:33 +0000
Re: Creating a function for a directory Neil Cerutti <neilc@norwich.edu> - 2013-11-12 13:42 +0000
Re: Creating a function for a directory Matt <mattgraves7@gmail.com> - 2013-11-11 15:05 -0800
Re: Creating a function for a directory Chris Angelico <rosuav@gmail.com> - 2013-11-12 09:51 +1100
Re: Creating a function for a directory unknown <unknown@unknown.com> - 2013-11-12 10:07 +0000
Re: Creating a function for a directory Peter Otten <__peter__@web.de> - 2013-11-12 11:24 +0100
Re: Creating a function for a directory unknown <unknown@unknown.com> - 2013-11-12 11:26 +0000
csiph-web