I frequently use command finalization hooks to print something just before returning to the prompt. I don't want the output to occur after each command running in a Python or text script though.
Currently I do the following to know if I'm in a script:
if self._in_py or self._current_script_dir is not None:
# In script
It would be better to provide developers with a method so they don't have to reference protected members.