bash/shell to python

Chris Angelico rosuav at gmail.com
Thu May 17 04:52:59 EDT 2012


On Thu, May 17, 2012 at 12:16 PM, Rita <rmorgan466 at gmail.com> wrote:
> Hello,
>
> I currently build a lot of interfaces/wrappers to other applications using
> bash/shell. One short coming for it is it lacks a good method to handle
> arguments so I switched to python a while ago to use 'argparse' module. Its
> a great complement to subprocess module. I was wondering if there is a
> generic framework people follow to build python scripts which are replacing
> shell scripts? Is there a guide or a template to follow?

It's generally accepted that it's easier to port a shell than a shell
script. That said, though, Python does have some good "shell-like"
functionality - look at the shutil module (along with subprocess which
you've already seen). To create optimal Python code, though, you're
going to have to look through the shell script, understand what it's
actually doing, and rewrite that logic in Python.

chrisA



More information about the Python-list mailing list