The few times I tried to de shell like things in Python, the absolute pain of actually running commands and getting to their output might be part of the reason.
What is A=$(cmd) in bash is an absolute pain in python.
What is A=$(cmd) in bash is an absolute pain in python.
def _call(cmd_str): return subprocess.check_output(shlex.split(cmd_str)).decode("utf-8")
Definitely a verbose monstrosity compared to doing it in bash, but more than worth avoiding the garbage fire that is Bash. And it only works for simple cases
They work well, if a bit magically, until you need to background a process.
Xonsh is an awesome fishy she'll that's a Python superset. $() is built right in.
_("ls -la") | _(lambda x: x.split()[-1]) | _(lambda x: os.path.splitext(x)[1])
I wonder if there's a complete version of something like this out there. You can probably get pretty far staying in Python-land, plus, everything else is free (data types, standard library, adoption, etc).A = !cmd