3 ms·
> python There's a library for Node called Zx (https://github.com/google/zx https://github.com/google/zx) that provides a more shell-liked interface for Node.
by nerdponx 3y ago
> python
There's a library for Node called Zx (https://github.com/google/zx https://github.com/google/zx) that provides a more shell-liked interface for Node.
I've been working on something in Python, inspired by Zx and Xonsh (https://xon.sh/ https://xon.sh/), with syntax like this:
from pathlib import Path
from pyshell import Pipeline
args = ["123", "456"]
f = Path("out.txt")
with Pipeline() as p:
p.exec("a") | p.exec("b", *args) | p.exec("c", "x", "y") >> f
Personally, the above would be hugely useful to me in reducing my temptation to write shell scripts, and significantly reducing the annoyance of doing these things in Python.
Is this something you'd use? It's slow going for me because it basically involves writing a compiler and I have approximately zero idea of what I'm doing. Knowing that other people would find it useful helps me stay motivated to keep working on it! Or if someone who theoretically is the primary audience doesn't find it useful, it might mean that I should spend my energy on other things.
- hereonout2 3y agoThis looks cool, especially if one needed to do a number of pipe operations from python, I'm not sure of an elegant way to do that already. Honestly I might be the wrong audience though, I've spent many years shell scripting and I find the flexibility of using the command line tools so great I choose to use it first despite the inadequacies of bash. I wonder if users with my point of view would ever be tempted away. Also the shell is an interactive repl, which to me is where a lot of the power lies. The number of times I've asked a junior things like what the total duration of a set of audio files is, or the average length or something. They often come back with a python script or worse a jupyter notebook and pandas. The answer can also often be found by combining things like grep and awk in a few seconds once you've become acquainted with the tools, I guess I do try and demonstrate / preach this where I can.