This documentation covers a development version of IPython. The development version may differ significantly from the latest stable release.
This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.
If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).
Magic functions for running cells in various scripts.
- class IPython.core.magics.script.ScriptMagics(**kwargs: Any)¶
Magics for talking to scripts
This defines a base
%%scriptcell magic for running a cell with a program in a subprocess, and registers a few top-level magics that call %%script with common interpreters.
Create a configurable given a config config.
config (Config) – If this is empty, default values are used. If config is a
Configinstance, it will be used to configure the instance.
parent (Configurable instance, optional) – The parent Configurable instance of this object.
Subclasses of Configurable must call the
Configurablebefore doing anything else and using
class MyConfigurable(Configurable): def __init__(self, config=None): super(MyConfigurable, self).__init__(config=config) # Then any other code you need to finish initialization.
This ensures that instances will be configured properly.
The event loop on which to run subprocesses
Not the main event loop, because we want to be able to make blocking calls and have certain requirements we don’t want to impose on the main loop.
Kill all BG processes which are still running.
Kill all BG processes started by %%script and its family.
Extra script cell magics to define
This generates simple wrappers of
If you want to add script magics that aren’t on your path, specify them in script_paths
Dict mapping short ‘ruby’ names to full paths, such as ‘/opt/secret/bin/ruby’
Only necessary for items in script_magics where the default path will not find the right interpreter.
- shebang(line, cell)¶
%shebang [--no-raise-error] [--proc PROC] [--bg] [--err ERR] [--out OUT]
Run a cell via a shell command
%%scriptline is like the #! line of script, specifying a program (bash, perl, ruby, etc.) with which to run.
The rest of the cell is run by that program.
In : %%script bash ...: for i in 1 2 3; do ...: echo $i ...: done 1 2 3
Whether you should raise an error message in addition to a stream on stderr if you get a nonzero exit code.
- --proc PROC
The variable in which to store Popen instance. This is used only when –bg option is given.
Whether to run the script in the background. If given, the only way to see the output of the command is with –out/err.
- --err ERR
The variable in which to store stderr from the script. If the script is backgrounded, this will be the stderr pipe, instead of the stderr text itself and will not be autoclosed.
- --out OUT
The variable in which to store stdout from the script. If the script is backgrounded, this will be the stdout pipe, instead of the stderr text itself and will not be auto closed.
single decorator for adding script args