Python as a scripting language. Alternative to bash script?

Mithrandir mithrandiragainwiki at mailinator.com
Wed Jun 30 15:31:16 EDT 2010


Michael Torrie <torriem at gmail.com> wrote in
news:mailman.2313.1277759925.32709.python-list at python.org: 

> On 06/28/2010 02:06 PM, Mithrandir wrote:
>> I can't see Python as an alt. to bash. (As I recall) Python is much
>> more object-oriented than bash, but also there are many commands
>> (such as apt- get, etc.) that would need Python equivs. However, I
>> can see Python being used as a scripting alt. to C.
> 
> OO is a plus for most things, in my book.  As for "commands" they have
> *nothing* to do with Bash.  apt-get is not a Bash command.  By your
> logic tcsh or zsh would not be an alternate to bash, but in fact they
> are. 
> 
> I use python for shell scripting quite often now.  Anytime one of my
> own Bash scripts exceeds 100 lines, I know it's time to switch it to
> python. 
>  Please read that link I posted a while back on how you can use
> generators in python to replace many of the things that piping to
> external commands did in Bash.
> 
> There certainly are a few tasks that Bash is best at (chaining
> commands together through pipes), but often Python already has support
> for many of the things I'd use external commands and pipes in Bash
> for.  Bash is designed for working down at the level of files,
> directories, and processes, but Python works pretty well too, if you
> make some abstraction modules like my runcmd module that I use
> extensively. 
> 

You both are correct. :) (I wrote that before my first cup of coffee, so my 
wording was way off. That, and I'm new to Python.) :)

I think that Python "could" be a alternative to bash and have some 
advantages, but it's a long way off from being fully implemented.




More information about the Python-list mailing list