I use it as a better shell. Scripting in bash or sh is a horrible experience, and pure Python lacks the conciseness of bash for simple exploration and manipulation of a file system hierarchy (cd, cp, mv, ls...).
For example, you can write stuff like
files = !ls -a
for f in files:
!diff $f "some_file"
if _exit_code != 0:
some_function(f)
and it even correctly handles spaces in file names. (what sorcery is this?!)
I'm using fish <http://fishshell.com/> for both scripting (saner syntax, space handling) and interactive (multiline syntax highlighted prompt) and never looked back.
But this makes me consider ipython again, perhaps even as main shell.
Hmm, after %rehashx I can use commands without !, e.g. git diff. <http://ipython.org/ipython-doc/stable/interactive/shell.html...
Moreover, this means I can have a notebook experience for my shell. Together with the new directory navigation and friendly URLs this is becoming very attractive!
There is however a deal-breaker: no smart completion for shell commands. But it'd be clearly possible to implement it by harnessing bash (or zsh or fish) for completions.
Wow. The one thing that makes bash scripting better than Python for certain things is that using the subprocess module makes your code really verbose. This fixes that.
> Not at all to pick a nit, but that still depends on bash or sh (the bang commands).
That's a good point, and not nit-picky at all. However, I think the dependency is on the Unix commands (mv, cp, ...), not bash or sh, which still makes this mixed approach unsuitable for truly platform-independent scripting.
Of course, this point is moot when you use it as your personal shell, or when scripting for your Unix servers, etc.
For example, you can write stuff like
and it even correctly handles spaces in file names. (what sorcery is this?!)