It is usually worth the context switch, especially when (a) the project already has several tools in play and/or (b) the alternative is much sharper. A situation that calls for expect, or for sed, for example, is likely to be much more easily solved than with python.
On the other hand, if you're working on a system that is almost exclusively python, it wouldn't make sense to use something only "very slightly sharper". E.g. calling out to perl to do some one-liner that needs 5 lines in python.
On the other hand, if you're working on a system that is almost exclusively python, it wouldn't make sense to use something only "very slightly sharper". E.g. calling out to perl to do some one-liner that needs 5 lines in python.