2 ms·
glob plays grep's role here. No need for a pipe. If you want to run a shell pipeline that is more challenging to port to pure Python, then you could the shell
by d0mine 3y ago
glob plays grep's role here. No need for a pipe.
If you want to run a shell pipeline that is more challenging to port to pure Python, then you could the shell directly:
S.run("a | b", shell=True)
You could emulate it in Python using the subprocess module but it would be more verbose. It depends on specific use-case whether it is worth the trouble.
Calling the shell pipeline from Python gets you the best of both worlds: a shell one liner is used as a concise domain specific language to run commands , and more complex logic, proper error handling, etc is left to Python.