script files with python (instead of tcsh/bash)?

MRAB google at mrabarnett.plus.com
Sun Mar 22 15:05:22 CET 2009


Esmail wrote:
> Nick Craig-Wood wrote:
>> Esmail <ebonak at hotmail.com> wrote:
>>>  I am wondering if anyone is using python to write script files?
>>
>> Yes!
>>
> <..>
>>
>> Almost any script that contains a loop I convert into python.
>>
>>>  In any case, the scripts are starting to look pretty hairy and I was
>>>  wondering if it would make sense to re-write them in Python. I am not
>>>  sure how suitable it would be for this.
>>
>> With python you get the advantages of a language with a very clear
>> philosophy which is exceptionally easy to read and write.
>>
>> Add a few classes and unit tests to your scripts and they will be
>> better than you can ever achieve with bash (IMHO).
> 
> 
> Hi Nick,
> 
> thanks for including the script, that really helps. Nice way of
> finding files.
> 
> Two quick questions:
> 
> As a replacement for grep I would use the re module and its methods?
> 
> What about awk which I regularly use to extract fields based on position
> but not column number, what should I be using in Python to do the same?
> 
Just use string slicing.

> The other things I need to do consist of moving files, manipulating file
> names and piping outputs of one command to the next, so I'm digging into
> the documentation as much as I can.
> 
The 'os' and 'shutil' modules.

> So much to learn, so little time (but so much fun!)
> 




More information about the Python-list mailing list