News for hackers. Stuff that matters.
Re:Why Create a New Unix Shell? by rocqua on Wednesday January 31, 2018 @04:11PM (#16277578)
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.

Re:Why Create a New Unix Shell? by wutbrodo on Wednesday January 31, 2018 @04:30PM (#16277722)
That was my main pain initially after I finally switched away from writing my scripts in Bash, but it actually turned out to be pretty easy. I wrote a quick helper function that does 99% of what I need:

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

Re:Why Create a New Unix Shell? by _mhr_ on Wednesday January 31, 2018 @08:41PM (#16279126)
Thank you for this.
Re:Why Create a New Unix Shell? by wryun on Wednesday January 31, 2018 @04:23PM (#16277671)
Have you tried plumbum or sh.py?

They work well, if a bit magically, until you need to background a process.

Re:Why Create a New Unix Shell? by vapemaster on Wednesday January 31, 2018 @05:15PM (#16278041)
Use xonsh!

Xonsh is an awesome fishy she'll that's a Python superset. $() is built right in.

Re:Why Create a New Unix Shell? by Goopplesoft on Thursday February 01, 2018 @12:46AM (#16279848)
A while back I wrote a little test snippet[1] to see how good such an interface can get in python.

    _("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).

[1] https://gist.github.com/pnegahdar/726cf2c65fc561db7831

Re:Why Create a New Unix Shell? by rollcat on Thursday February 01, 2018 @02:26PM (#16284966)
Try playing with __getattr__, I'm sure "_.method" instead of "_(lambda x: x.method())" could be a thing.
Re:Why Create a New Unix Shell? by bobbyi_settv on Thursday February 01, 2018 @01:55AM (#16280068)
subprocess.check_output(cmd) runs a command and returns the output, raising an exception if the command fails.
Re:Why Create a New Unix Shell? by camel_Snake on Friday February 02, 2018 @01:29AM (#16288815)
you can do this in ipython

A = !cmd