Why doesn't the last _ _ command variable appear in dir ()?

The first line after running the Python 2.7 interpreter on Windows:

>>> dir()
['__builtins__', '__doc__', '__name__', '__package__']

By entering the command dir(), you should define a special variable _:

>>> _
['__builtins__', '__doc__', '__name__', '__package__']

But even after input, _it does not appear when I try to list all the names in the interactive namespace using dir():

>>> dir()
['__builtins__', '__doc__', '__name__', '__package__']

How does the interpreter recognize this variable if it is not in the interpreter namespace?

+6
source share
1 answer

_ It is part of the built-in namespace, not global.

>>> import __builtin__
>>> 3
3
>>> __builtin__._
3

dir() does not list built-in functions:

With no arguments, return a list of names in the current local scope.

, dir().

+10

All Articles