how to get os.system () call to cooperate on Windows

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Oct 28 00:43:21 EDT 2009


En Tue, 27 Oct 2009 23:04:47 -0300, Steven D'Aprano  
<steven at remove.this.cybersource.com.au> escribió:
> On Tue, 27 Oct 2009 21:48:36 -0300, Gabriel Genellina wrote:
>> En Tue, 27 Oct 2009 10:55:09 -0300, TerryP <bigboss1964 at gmail.com>
>> escribió:
>>> On Oct 26, 10:00 am, Anthra Norell <anthra.nor... at bluewin.ch> wrote:

>>>> How can one copy files on the OS level?
>> from ctypes import windll
>> CopyFile = windll.kernel32.CopyFileA
>> CopyFile("d:\\temp\\old.txt", "d:\\temp\\new.txt", True)
>
> Have I missed something? What's wrong with shutil?

There's nothing wrong with shutil, but CopyFile and friends have some  
additional features (correct handling of alternate data streams, progress  
callback, reduced disk fragmentation...) that some people may be  
interested in.

The idea was just to show how to call CopyFile using ctypes, not implying  
that it's the only way to do that. Everyone knows that the One and True  
Way of copying files is using PIP.

-- 
Gabriel Genellina




More information about the Python-list mailing list