MCPcopy Index your code
hub / github.com/ipython/ipython / who_ls

Method who_ls

IPython/core/magics/namespace.py:247–284  ·  view source on GitHub ↗

Return a sorted list of all interactive variables. If arguments are given, only variables of types matching these arguments are returned. Examples -------- Define two variables and list them with who_ls:: In [1]: alpha = 123 In [2]: bet

(self, parameter_s='')

Source from the content-addressed store, hash-verified

245 @skip_doctest
246 @line_magic
247 def who_ls(self, parameter_s=''):
248 """Return a sorted list of all interactive variables.
249
250 If arguments are given, only variables of types matching these
251 arguments are returned.
252
253 Examples
254 --------
255 Define two variables and list them with who_ls::
256
257 In [1]: alpha = 123
258
259 In [2]: beta = 'test'
260
261 In [3]: %who_ls
262 Out[3]: ['alpha', 'beta']
263
264 In [4]: %who_ls int
265 Out[4]: ['alpha']
266
267 In [5]: %who_ls str
268 Out[5]: ['beta']
269 """
270
271 user_ns = self.shell.user_ns
272 user_ns_hidden = self.shell.user_ns_hidden
273 nonmatching = object() # This can never be in user_ns
274 out = [ i for i in user_ns
275 if not i.startswith('_') \
276 and (user_ns[i] is not user_ns_hidden.get(i, nonmatching)) ]
277
278 typelist = parameter_s.split()
279 if typelist:
280 typeset = set(typelist)
281 out = [i for i in out if type(user_ns[i]).__name__ in typeset]
282
283 out.sort()
284 return out
285
286 @skip_doctest
287 @line_magic

Callers 4

whoMethod · 0.95
whosMethod · 0.95
resetMethod · 0.95
reset_selectiveMethod · 0.95

Calls 2

getMethod · 0.80
sortMethod · 0.80

Tested by

no test coverage detected