There's an escape sequence for shell commands, and an escape sequence within that for ordinary Python code. It works fine.
The reality is that most Unix DSLs are similar to subsets of Python. Yes, Python is not the global optimum of programming languages forever more amen, but most Unix DSLs are effectively just ad-hoc procedural languages, and therefore special cases of Python. And if you're going to use Python aggressively for other things, then there's a benefit to using it as a shell as well, and thereby get some consistency.
The reality is that most Unix DSLs are similar to subsets of Python. Yes, Python is not the global optimum of programming languages forever more amen, but most Unix DSLs are effectively just ad-hoc procedural languages, and therefore special cases of Python. And if you're going to use Python aggressively for other things, then there's a benefit to using it as a shell as well, and thereby get some consistency.