First line once Python 2.7 interpreter is started on Windows:
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__']
Having entered the dir()
command, the special variable _
should be defined:
>>> _
['__builtins__', '__doc__', '__name__', '__package__']
But, even after entering _
, it does not show up when I attempt to list all 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's namespace?
_
goes in the built-in namespace, not the globals.
>>> import __builtin__
>>> 3
3
>>> __builtin__._
3
dir()
doesn't list built-ins:
Without arguments, return the list of names in the current local scope.
The built-in scope is a different scope from the one you're running dir()
in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With