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

Method who

IPython/core/magics/namespace.py:288–348  ·  view source on GitHub ↗

Print all interactive variables, with some minimal formatting. If any arguments are given, only variables whose type matches one of these are printed. For example:: %who function str will only list functions and strings, excluding all other types of vari

(self, parameter_s='')

Source from the content-addressed store, hash-verified

286 @skip_doctest
287 @line_magic
288 def who(self, parameter_s=''):
289 """Print all interactive variables, with some minimal formatting.
290
291 If any arguments are given, only variables whose type matches one of
292 these are printed. For example::
293
294 %who function str
295
296 will only list functions and strings, excluding all other types of
297 variables. To find the proper type names, simply use type(var) at a
298 command line to see how python prints type names. For example:
299
300 ::
301
302 In [1]: type('hello')\\
303 Out[1]: <type 'str'>
304
305 indicates that the type name for strings is 'str'.
306
307 ``%who`` always excludes executed names loaded through your configuration
308 file and things which are internal to IPython.
309
310 This is deliberate, as typically you may load many modules and the
311 purpose of %who is to show you only what you&#x27;ve manually defined.
312
313 Examples
314 --------
315
316 Define two variables and list them with who::
317
318 In [1]: alpha = 123
319
320 In [2]: beta = 'test'
321
322 In [3]: %who
323 alpha beta
324
325 In [4]: %who int
326 alpha
327
328 In [5]: %who str
329 beta
330 """
331
332 varlist = self.who_ls(parameter_s)
333 if not varlist:
334 if parameter_s:
335 print('No variables match your requested type.')
336 else:
337 print('Interactive namespace is empty.')
338 return
339
340 # if we have variables, move on...
341 count = 0
342 for i in varlist:
343 print(i+'\t', end=' ')
344 count += 1
345 if count > 8:

Callers

nothing calls this directly

Calls 1

who_lsMethod · 0.95

Tested by

no test coverage detected