os.system function

Zabin zabin.farishta at gmail.com
Mon Jan 11 17:00:44 EST 2010


On Jan 12, 10:23 am, Chris Rebert <c... at rebertia.com> wrote:
> On Mon, Jan 11, 2010 at 12:43 PM, Zabin <zabin.faris... at gmail.com> wrote:
> > Hey everyone!
>
> > I am a new python programmer. I am trying to get the general file
> > functionality with options of save and save as working. These save
> > functions save a folder with multiple files. Upon using the os.system
> > copy function- if my destination directory has files with similar
> > names- i am asked whether i want to replace the files on the command
> > prompt.
>
> > Is there some way of getting this question into a dialog box?
>
> > Also is there someway of avoiding or programmatically setting the
> > response to the command prompt?
>
> You can probably avoid using os.system() entirely (always a good
> thing) by instead using the functions in the `shutil` library:http://docs.python.org/library/shutil.html
>
> And for future reference, the `subprocess` module is the preferred way
> to invoke external programs, rather than os.system():http://docs.python.org/library/subprocess.html
>
> Cheers,
> Chris
> --http://blog.rebertia.com

Thanks for the pointers....i had a look around and found the site:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true

to disable the prompt- i needed to include /y as below:
 os.system ('xcopy /s %s %s /y ' % (dirExe, dirname_new))


and just wondering- whats the drawback of using os.system() command

Appreciate the prompt suggestions!

Cheers
Zabin



More information about the Python-list mailing list