Why python shell stores last expression in _ variable but python file does not?

44 Views Asked by At

I ran below code in python shell and from a python file, I expected the same output but ironically i get NameError: name '_' is not defined error in python file.

>>> 10+2
12
>>> print(_)
12

So i started wondering why python shell stores last expression in _ variable but it is not even defined in python file.

0

There are 0 best solutions below