##// END OF EJS Templates
Merge pull request #4543 from minrk/whos-startup...
Paul Ivanov -
r13628:85b169fa merge
parent child Browse files
Show More
@@ -0,0 +1,12 b''
1 changes to hidden namespace on startup
2 --------------------------------------
3
4 Previously, all names declared in code run at startup
5 (startup files, ``ipython -i script.py``, etc.)
6 were added to the hidden namespace, which hides the names from tools like ``%whos``.
7 There are two changes to this behavior:
8
9 1. Scripts run on the command-line ``ipython -i script.py``now behave the same as if they were
10 passed to ``%run``, so their variables are never hidden.
11 2. A boolean config flag ``InteractiveShellApp.hide_initial_ns`` has been added to optionally
12 disable the hidden behavior altogether. The default behavior is unchanged.
@@ -163,6 +163,11 b' class InteractiveShellApp(Configurable):'
163
163
164 # Extensions that are always loaded (not configurable)
164 # Extensions that are always loaded (not configurable)
165 default_extensions = List(Unicode, [u'storemagic'], config=False)
165 default_extensions = List(Unicode, [u'storemagic'], config=False)
166
167 hide_initial_ns = Bool(True, config=True,
168 help="""Should variables loaded at startup (by startup files, exec_lines, etc.)
169 be hidden from tools like %who?"""
170 )
166
171
167 exec_files = List(Unicode, config=True,
172 exec_files = List(Unicode, config=True,
168 help="""List of files to run at IPython startup."""
173 help="""List of files to run at IPython startup."""
@@ -282,15 +287,19 b' class InteractiveShellApp(Configurable):'
282 self._run_startup_files()
287 self._run_startup_files()
283 self._run_exec_lines()
288 self._run_exec_lines()
284 self._run_exec_files()
289 self._run_exec_files()
290
291 # Hide variables defined here from %who etc.
292 if self.hide_initial_ns:
293 self.shell.user_ns_hidden.update(self.shell.user_ns)
294
295 # command-line execution (ipython -i script.py, ipython -m module)
296 # should *not* be excluded from %whos
285 self._run_cmd_line_code()
297 self._run_cmd_line_code()
286 self._run_module()
298 self._run_module()
287
299
288 # flush output, so itwon't be attached to the first cell
300 # flush output, so itwon't be attached to the first cell
289 sys.stdout.flush()
301 sys.stdout.flush()
290 sys.stderr.flush()
302 sys.stderr.flush()
291
292 # Hide variables defined here from %who etc.
293 self.shell.user_ns_hidden.update(self.shell.user_ns)
294
303
295 def _run_exec_lines(self):
304 def _run_exec_lines(self):
296 """Run lines of code in IPythonApp.exec_lines in the user's namespace."""
305 """Run lines of code in IPythonApp.exec_lines in the user's namespace."""
General Comments 0
You need to be logged in to leave comments. Login now