MCPcopy Create free account
hub / github.com/ipython/ipython / who

Method who

IPython/core/magics/namespace.py:289–349  ·  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

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

Callers

nothing calls this directly

Calls 1

who_lsMethod · 0.95

Tested by

no test coverage detected