Opinion on best practice...

Walter Hurry walterhurry at lavabit.com
Tue Feb 5 16:01:56 EST 2013


On Tue, 05 Feb 2013 13:22:02 +0000, Grant Edwards wrote:

> On 2013-02-05, Anthony Correia <akcorreia at gmail.com> wrote:
> 
>> I need to pick up a language that would cover the Linux platform.
> 
> Well, you haven't really described what it is you're trying to do, but
> it looks to me like bash and the usual set of shell utilities (e.g.
> find) is what you need rather than Python.
> 
>> 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?
> 
> That depends.  What is "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)
> 
> Sorry, I'm a Linux guy.  I have no clue what that means.

Hooray for common sense! Python is great, but it's silly to use Python 
(unless there is good reason) when a simple shell script will do the job.

I think he means (bash speak):

for file in <whateverdir>




More information about the Python-list mailing list