Vanilla Python REPL:
>>> 'na'
'na'
>>> for i in range(4):
... f'{_+_}'
... else:
... 'batman'
...
'nana'
'nananana'
'nananananananana'
'nananananananananananananananana'
'batman'
>>>
IPython REPL with same interpreter:
>>> 'na'
'na'
>>> for i in range(4):
... f'{_+_}'
... else:
... 'batman'
...
>>> _
'na'
This difference is apparently related to the mode in which IPython compiles code, and unrelated to the display hook. Is it possible to configure IPython to compile/exec cell blocks as a plain Python REPL does? I'd prefer if IPython would not interfere or modify such underlying runtime machinery.