Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88457
| References | <6203299c-f9b2-4169-9d68-4c92e0f7b32f@googlegroups.com> <mailman.18.1427977502.12925.python-list@python.org> <57693d65-e683-4972-ac8d-97b2feace3bb@googlegroups.com> <mailman.21.1427979994.12925.python-list@python.org> <33906269-3688-48fc-8315-e88eac644ace@googlegroups.com> |
|---|---|
| Date | 2015-04-03 00:57 +1100 |
| Subject | Re: New to Programming: TypeError: coercing to Unicode: need string or buffer, list found |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.22.1427983064.12925.python-list@python.org> (permalink) |
On Fri, Apr 3, 2015 at 12:28 AM, Saran A <ahlusar.ahluwalia@gmail.com> wrote:
> Does this modification to copyFile do the job of moving the file? I haven't written a test yet.
>
> Thanks for catching the indentation for the helper functions.
>
> def copyFile(src, dest):
>> > try:
>> > shutil.rename(src, dest)
>> > # eg. src and dest are the same file
>> > except shutil.Error as e:
>> > print('Error: %s' % e)
>> > # eg. source or destination doesn't exist
>> > except IOError as e:
>> > print('Error: %s' % e.strerror)
You shouldn't need shutil here; just os.rename(src, dest) should do
the trick. But be careful! Now you have a function which moves a file,
and it's called "copyFile". If its purpose changes, so should its
name.
Have fun!
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
New to Programming: TypeError: coercing to Unicode: need string or buffer, list found Saran A <ahlusar.ahluwalia@gmail.com> - 2015-04-02 05:02 -0700
Re: New to Programming: TypeError: coercing to Unicode: need string or buffer, list found Chris Angelico <rosuav@gmail.com> - 2015-04-02 23:24 +1100
Re: New to Programming: TypeError: coercing to Unicode: need string or buffer, list found Saran A <ahlusar.ahluwalia@gmail.com> - 2015-04-02 05:46 -0700
Re: New to Programming: TypeError: coercing to Unicode: need string or buffer, list found Chris Angelico <rosuav@gmail.com> - 2015-04-03 00:06 +1100
Re: New to Programming: TypeError: coercing to Unicode: need string or buffer, list found Saran A <ahlusar.ahluwalia@gmail.com> - 2015-04-02 06:28 -0700
Re: New to Programming: TypeError: coercing to Unicode: need string or buffer, list found Chris Angelico <rosuav@gmail.com> - 2015-04-03 00:57 +1100
Re: New to Programming: TypeError: coercing to Unicode: need string or buffer, list found Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-04-02 20:03 -0400
Re: New to Programming: TypeError: coercing to Unicode: need string or buffer, list found Saran A <ahlusar.ahluwalia@gmail.com> - 2015-04-02 17:14 -0700
Re: New to Programming: TypeError: coercing to Unicode: need string or buffer, list found Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-04-03 11:33 -0400
Re: New to Programming: TypeError: coercing to Unicode: need string or buffer, list found Chris Angelico <rosuav@gmail.com> - 2015-04-03 11:12 +1100
Re: New to Programming: TypeError: coercing to Unicode: need string or buffer, list found Peter Otten <__peter__@web.de> - 2015-04-02 14:26 +0200
Re: New to Programming: TypeError: coercing to Unicode: need string or buffer, list found Saran A <ahlusar.ahluwalia@gmail.com> - 2015-04-02 05:51 -0700
csiph-web