It makes debugging and R&D really easy.
For example say I have a script:
data = slow_computation()
metrics = produce_metrics(data)
Now later I want to play with some metrics and experiment a bit I can do that in the interactive shell (running with python -i file.py will run the script as normal but leave a python interpreter open at the end with all the variables kept alive)
When I am happy with my experimentation results, say, I have found something interesting about the data and written a new function cool_metric(metrics) I can commit it to the script at the end
data = slow_computation()
metrics = produce_metrics(data)
cool_metric = cool_metric(metrics)
There's also the ability to drop in breakpoints where you can then have the full python shell available, can break out of the debugger into an interactive shell if you want, or can modify a variable and then continue the script as normal. I think you can do that with GDB for instance but it's not quite as flexible if I am not mistaken?
so if I have
def some_buggy_function(args):
data = analyse(args)
breakpoint()
new_data = further_analyse(data)
that can be quite powerful in making debugging easy