diff --git a/IPython/core/shellapp.py b/IPython/core/shellapp.py index 24f6825..f46a0e5 100644 --- a/IPython/core/shellapp.py +++ b/IPython/core/shellapp.py @@ -287,16 +287,19 @@ class InteractiveShellApp(Configurable): self._run_startup_files() self._run_exec_lines() self._run_exec_files() + + # Hide variables defined here from %who etc. + if self.hide_initial_ns: + self.shell.user_ns_hidden.update(self.shell.user_ns) + + # command-line execution (ipython -i script.py, ipython -m module) + # should *not* be excluded from %whos self._run_cmd_line_code() self._run_module() # flush output, so itwon't be attached to the first cell sys.stdout.flush() sys.stderr.flush() - - # Hide variables defined here from %who etc. - if self.hide_initial_ns: - self.shell.user_ns_hidden.update(self.shell.user_ns) def _run_exec_lines(self): """Run lines of code in IPythonApp.exec_lines in the user's namespace."""