From 6e3bea50503d0bbafbdf476b290c64f91d57abb0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 31 Jan 2014 11:42:05 +0530 Subject: [PATCH] Add some common modules into the interactive shell names by default --- src/calibre/utils/ipython.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/utils/ipython.py b/src/calibre/utils/ipython.py index 674356289f..1ddd7de960 100644 --- a/src/calibre/utils/ipython.py +++ b/src/calibre/utils/ipython.py @@ -7,7 +7,7 @@ __license__ = 'GPL v3' __copyright__ = '2012, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import os +import os, re, sys from calibre.constants import iswindows, cache_dir, get_version ipydir = os.path.join(cache_dir(), 'ipython') @@ -164,8 +164,12 @@ def ipython(user_ns=None): from IPython.config.loader import Config except ImportError: return simple_repl(user_ns=user_ns) + defns = {'os':os, 're':re, 'sys':sys} if not user_ns: - user_ns = {} + user_ns = defns + else: + user_ns = defns.updatu(user_ns) + c = Config() c.InteractiveShellApp.exec_lines = [ 'from __future__ import division, absolute_import, unicode_literals, print_function',