Problem with os.system()

venutaurus539 at gmail.com venutaurus539 at gmail.com
Wed Feb 25 00:28:27 EST 2009


On Feb 25, 9:55 am, Christian Heimes <li... at cheimes.de> wrote:
> venutaurus... at gmail.com schrieb:
>
> > Hello,
> >          I am facing problems while using os.system() of python for
> > copying a file from source to destination where the file name is in
> > unicode (multi lingual characters).My python interpreter is trying to
> > convert them to ascii and is failing. I tried giving unicode string as
> > input for the function something like:
>
> > c = u"copy "+"\""+full_path+"\" "+dest
> > os.system (c)
>
> First of all do not use os.system() to run external programs. You'll get
> in all sorts of trouble like quoting. You are far better of with the
> subprocess module.
>
> Second, why are you using an external program at all? The shutil module
> contains multiple functions to copy a file or directory.
>
> import shutil
> shutil.copy(source, dest)
>
> Christian

Thanks Christian for your reply,will definitely try.



More information about the Python-list mailing list