printvars#

printvars(localvars=None, varlist=None, label=None, divider=True, spaces=1, color=None)[source]#

Print out a list of variables. Note that the first argument must be locals().

Parameters:
  • localvars – function must be called with locals() as first argument

  • varlist – the list of variables to print out

  • label – optional label to print out, so you know where the variables came from

  • divider – whether or not to offset the printout with a spacer (i.e. ——)

  • spaces – how many spaces to use between variables

  • color – optionally label the variable names in color so they’re easier to see

Example:

>>> a = range(5)
>>> b = 'example'
>>> sc.printvars(locals(), ['a','b'], color='green')

Another useful usage case is to print out the kwargs for a function:

>>> sc.printvars(locals(), kwargs.keys())

Version: 2017oct28