How do I reset the underscore in an interactive session?

python, read-eval-print-loop

Solution

del _

A global `_` shadows the builtin `_`, so deleting the global reveals the builtin again.

It's also worth noting that it doesn't actually stop working, it's just not accessible. You can import builtins to access it:

>>> _ = 'foobar'
>>> 22
22
>>> _
'foobar'
>>> import builtins
>>> 23
23
>>> builtins._
23

Problem

I have overriden the underscore variable `_` in the Python interactive interpreter. How can I make the underscore work again without restarting the interpreter?

Original source

Related problems