Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reset the underscore in an interactive session? [duplicate]

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

like image 287
Vi Ki Avatar asked Nov 03 '25 17:11

Vi Ki


1 Answers

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
like image 97
wjandrea Avatar answered Nov 05 '25 08:11

wjandrea