Opinion on best practice...

Anthony Correia akcorreia at gmail.com
Mon Feb 4 23:14:14 EST 2013


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)




More information about the Python-list mailing list