Magic command %who_ls does not list variables with underscore at the beginning
Author: willeppyCreated Nov 9, 2022Updated Sep 26, 2026
Labelsdocumentation
When running the magic command %who_ls, any variables with an underscore at the beginning like _x will not be listed. Is this intentional behavior?
I noticed this in Jupyterlab, however was able to replicate in the IPython terminal from command line:
Python 3.10.6 (main, Oct 24 2022, 11:04:34) [Clang 12.0.0 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.6.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: x = 1
In [2]: _y = 1
In [3]: %who_ls
Out[3]: ['x']I know that the convention is variables with an underscore are "private", however this is unexpected behavior to me since _y is a normal python variable. Perhaps the docs should be updated if this is intentional and not a bug? https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-who_ls
Source: ipython/ipython