def mini_interactive_loop(input_func):
 from IPython.core.inputsplitter import InputSplitter
 isp = InputSplitter()
 while isp.push_accepts_more():
  indent = (' ' * isp.indent_spaces)
  prompt = ('>>> ' + indent)
  line = (indent + input_func(prompt))
  isp.push(line)
 src = isp.source_reset()
 return src

def mini_interactive_loop ( input_func ) : from IPython . core . inputsplitter import InputSplitter isp = InputSplitter ( ) while isp . push_accepts_more ( ) : indent = ( ' ' * isp . indent_spaces ) prompt = ( '>>> ' + indent ) line = ( indent + input_func ( prompt ) ) isp . push ( line ) src = isp . source_reset ( ) return src
minimal example of the logic of an interactive interpreter loop .