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

Esmail ebonak at hotmail.com
Mon Mar 23 09:55:56 EDT 2009


MRAB wrote:
> 
>> 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.

Would that be equivalent to splitting the string and then subscripting
on the result?

That seems to be the closest to awk .. wouldn't string slicing depend on
column numbers for the line (so to speak)i.e, specific know index values?

>> 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.

Excellent, thanks for the pointers. I was aware of the os module, but
didn't know about the shutil module. The more I dig into Python, the
more I like it and the more I'm impressed. (I do miss bock comments,
when you are trying out new things that is useful .. I know I can use
""" as a substitute though).

Thanks again,
Esmail




More information about the Python-list mailing list