From 14303979f1ed4e564f8b3ed47925dbd7b26b14e5 Mon Sep 17 00:00:00 2001 From: Wirawan Purwanto Date: Thu, 16 Feb 2012 13:53:58 -0500 Subject: [PATCH] * Recorded down some notes/caveat for init_interactive(). --- interactive_tools.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/interactive_tools.py b/interactive_tools.py index 07a8585..a7b6cd4 100644 --- a/interactive_tools.py +++ b/interactive_tools.py @@ -6,6 +6,8 @@ # # Simple and dirty tools for interactive python mode # +# FIXME TODO LIST: +# - needs to detect 'python -i' presence in case of python <= 2.5. import atexit import inspect @@ -96,11 +98,16 @@ def init_interactive(use_readline=True, global_ns=None): """Perform standard initialization for my scripts. Some options can be given to tweak the environment. - Under ipython - """ - # ERROR: this still does not work. we need to execute the statements - # in the global (base) namespace, not in this function's namespace. + CAVEAT: this method still does not work universally yet. + We need to execute some of the statements in the global (top level) + namespace, not in this function's namespace. + So in general init_interactive *MUST* at this point be called from the + main program, not from any subroutine. + Otherwise, you must explicitly specify the global namespace as the + `global_ns` argument. + Works under ipython, `python -i' and vanilla python. + """ (g, b) = get_global_namespace_(global_ns) int_info = detect_interactive(g)