3 ms·
> In [3]: !echo "$file" | awk '!/^;;/' That's Bash (or at least sh). Which excels at piping the output of programs into other programs, and pay that cost for e
by palunon 8y ago
> In [3]: !echo "$file" | awk '!/^;;/'
That's Bash (or at least sh). Which excels at piping the output of programs into other programs, and pay that cost for everything else.
- dbdjfjrjvebd 8y agoYep. IPython lets you execute bash.
- klibertp 8y agoYeah, that's what I mean by "easy access" - you're working with Python, but if you want to do something that Python is not well-suited for[1] - like easily piping something through many programs - you can do it simply by adding `!` at the beginning of your pipeline, right there in the REPL. It's actually the same philosophy that shells use: in bash you frequently invoke sed, awk, grep, etc. because it's easier than writing the same directly in the shell. In IPython, you invoke bash to do piping, because it's easier than connecting a host of subprocesses' stdins/stdouts in Python. So again, there are some things you expect from your shell, and as long as you get those things (no matter how), you can use any REPL as a shell without problems. [1] because of syntax or lack of library or something like that
- wlib 8y agoPiping program output is just function composition. The downside is that it works over expensive system processes, and data must be serialized. It's a fragile system where instead of using built-in functions, we use "standard" executables.
- yesenadam 8y agoI think, rather, function composition is just piping program output.