Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ptpython/ipython.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,24 @@ def initialize_extensions(shell, extensions):
"Error in loading extension: %s" % ext +
"\nCheck your config files in %s" % ipy_utils.path.get_ipython_dir())
shell.showtraceback()

def run_exec_lines(shell, exec_lines):
"""
Partial copy of run_exec_lines code from IPython.core.shellapp .
"""
try:
iter(exec_lines)
except TypeError:
pass
else:
try:
for line in exec_lines:
try:
shell.run_cell(line, store_history=False)
except:
shell.showtraceback()
except:
shell.showtraceback()


def embed(**kwargs):
Expand All @@ -240,4 +258,5 @@ def embed(**kwargs):
kwargs['config'] = config
shell = InteractiveShellEmbed.instance(**kwargs)
initialize_extensions(shell, config['InteractiveShellApp']['extensions'])
run_exec_lines(shell, config['InteractiveShellApp']['exec_lines'])
shell(header=header, stack_depth=2, compile_flags=compile_flags)