Opinion on best practice...
Grant Edwards
invalid at invalid.invalid
Tue Feb 5 08:23:16 EST 2013
On 2013-02-05, Terry Reedy <tjreedy at udel.edu> wrote:
> On 2/4/2013 11:14 PM, Anthony Correia wrote:
>> I need to pick up a language that would cover the Linux platform. I use Powershell for a scripting language on the Windows side of things. Very simple copy files script. Is this the best way to do it?
>>
>> import os
>>
>> objdir = ("C:\\temp2")
>> colDir = os.listdir(objdir)
>> for f in colDir:
>> activefile = os.path.join(objdir + "\\" + f)
>> print ("Removing " + activefile + " from " + objdir)
>> os.remove(activefile)
>>
>> In Powershell I would just do:
>>
>> $colDir = gci -path "c:\temp2"
>> ForEach($file in $colDir)
>
> Python comes with a shutil module with multiple copy functions.
Most of the time when I find myself using the shutil module, it means
the program should have been written in bash. :)
--
Grant Edwards grant.b.edwards Yow! A shapely CATHOLIC
at SCHOOLGIRL is FIDGETING
gmail.com inside my costume..
More information about the Python-list
mailing list