You are viewing an older version (9.5.0). Go to latest (9.13.0)
{ } Raw JSON

bundles / IPython 9.5.0 / IPython / core / interactiveshell / InteractiveShell / safe_execfile

function

IPython.core.interactiveshell:InteractiveShell.safe_execfile

source: /IPython/core/interactiveshell.py :2878

Signature

def   safe_execfile ( self fname * where exit_ignore = False raise_exceptions = False shell_futures = False )

Summary

A safe version of the builtin execfile().

Extended Summary

This version will never throw an exception, but instead print helpful error messages to the screen. This only works on pure Python files with the .py extension.

Parameters

fname : string

The name of the file to be executed.

*where : tuple

One or two namespaces, passed to execfile() as (globals,locals). If only one is given, it is passed as both.

exit_ignore : bool (False)

If True, then silence SystemExit for non-zero status (it is always silenced for zero status, as it is so common).

raise_exceptions : bool (False)

If True raise exceptions everywhere. Meant for testing.

shell_futures : bool (False)

If True, the code will share future statements with the interactive shell. It will both be affected by previous __future__ imports, and any __future__ imports in the code will affect the shell. If False, __future__ imports are not shared in either direction.

Aliases

  • IPython.InteractiveShell.safe_execfile