Re: Creating a function for a directory

2013-11-12 Thread unknown
On Mon, 11 Nov 2013 14:26:46 -0800, Matt 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. def

Re: Creating a function for a directory

2013-11-12 Thread Peter Otten
unknown wrote: On Mon, 11 Nov 2013 14:26:46 -0800, Matt 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.

Re: Creating a function for a directory

2013-11-12 Thread unknown
On Tue, 12 Nov 2013 11:24:02 +0100, Peter Otten wrote: unknown wrote: On Mon, 11 Nov 2013 14:26:46 -0800, Matt 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

Re: Creating a function for a directory

2013-11-12 Thread Neil Cerutti
On 2013-11-12, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Using os.path.exists before opening a file is, for the most part, a waste of time. I use it in conjuction with file creation times to check that I didn't forget to update/create one of the data files a process might

Re: Creating a function for a directory

2013-11-11 Thread Joel Goldstick
On Mon, Nov 11, 2013 at 5:26 PM, Matt mattgrav...@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

Re: Creating a function for a directory

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 9:26 AM, Matt mattgrav...@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

Re: Creating a function for a directory

2013-11-11 Thread bob gailer
On 11/11/2013 5:26 PM, Matt 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. def firstdev(file):

Re: Creating a function for a directory

2013-11-11 Thread Joel Goldstick
Sorry for incorect answer. Those guys nailed it On Nov 11, 2013 5:43 PM, bob gailer bgai...@gmail.com wrote: On 11/11/2013 5:26 PM, Matt 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

Re: Creating a function for a directory

2013-11-11 Thread Mark Lawrence
On 11/11/2013 22:26, Matt 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. def firstdev(file):

Re: Creating a function for a directory

2013-11-11 Thread Rick Johnson
On Monday, November 11, 2013 4:26:46 PM UTC-6, Matt 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. def

Re: Creating a function for a directory

2013-11-11 Thread Matt
Thank you guys so much. Brain fart moment. I appreciate it -- https://mail.python.org/mailman/listinfo/python-list

Re: Creating a function for a directory

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 9:51 AM, Rick Johnson rantingrickjohn...@gmail.com wrote: On Monday, November 11, 2013 4:26:46 PM UTC-6, Matt 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

Re: Creating a function for a directory

2013-11-11 Thread Steven D'Aprano
On Mon, 11 Nov 2013 14:51:45 -0800, Rick Johnson wrote: 2. Never, ever, *EVER* write data to disc before confirming the paths your passing are pointing to the location you intended to write the data. Use os.path.exists(path) to test your paths BEFORE trying to write data. This is subject to

Re: Creating a function for a directory

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 9:44 AM, Joel Goldstick joel.goldst...@gmail.com wrote: Sorry for incorect answer. Those guys nailed it Your answer wasn't incorrect, because it didn't give any false information. Bob and I saw the problem itself and gave advice, but you gave useful general advice on how

Re: Creating a function for a directory

2013-11-11 Thread Rick Johnson
On Monday, November 11, 2013 5:11:52 PM UTC-6, Chris Angelico wrote: On Tue, Nov 12, 2013 at 9:51 AM, Rick Johnson 1. i believe win32 file paths require a qualifying volume letter. They do not; omitting the drive letter makes the path relative to the current drive (and since it doesn't

Re: Creating a function for a directory

2013-11-11 Thread Chris Angelico
On Tue, Nov 12, 2013 at 4:42 PM, Rick Johnson rantingrickjohn...@gmail.com wrote: On Monday, November 11, 2013 5:11:52 PM UTC-6, Chris Angelico wrote: On Tue, Nov 12, 2013 at 9:51 AM, Rick Johnson 1. i believe win32 file paths require a qualifying volume letter. They do not; omitting the