Generic utilities for use by IPython’s various subsystems.
Extract a set of variables by name from another frame.
Parameters: |
|
---|
frame.
Keywords: |
|
---|
Examples:
- In [2]: def func(x):
- ...: y = 1 ...: print extractVars(‘x’,’y’) ...:
In [3]: func(‘hello’) {‘y’: 1, ‘x’: ‘hello’}
Extract a set of variables by name from another frame.
Similar to extractVars(), but with a specified depth of 1, so that names are exctracted exactly from above the caller.
This is simply a convenience function so that the very common case (for us) of skipping exactly 1 frame doesn’t have to construct a special dict for keyword passing.
Always return a list of strings, given a string or list of strings as input.
Examples: | In [7]: list_strings(‘A single string’) Out[7]: [‘A single string’] In [8]: list_strings([‘A single string in a list’]) Out[8]: [‘A single string in a list’] In [9]: list_strings([‘A’,’list’,’of’,’strings’]) Out[9]: [‘A’, ‘list’, ‘of’, ‘strings’] |
---|
Return the input string centered in a ‘marquee’.
Examples: | In [16]: marquee(‘A test’,40) Out[16]: ‘************ A test ************‘ In [17]: marquee(‘A test’,40,’-‘) Out[17]: ‘—————- A test —————-‘ In [18]: marquee(‘A test’,40,’ ‘) Out[18]: ‘ A test ‘ |
---|
Expand $VARS and ~names in a string, like a shell
Examples: | In [2]: os.environ[‘FOO’]=’test’ In [3]: shexp(‘variable FOO is $FOO’) Out[3]: ‘variable FOO is test’ |
---|