##// END OF EJS Templates
Merge pull request #4606 from takluyver/optional-pythonstartup...
Matthias Bussonnier -
r13796:6980c6a4 merge
parent child Browse files
Show More
@@ -172,6 +172,10 b' class InteractiveShellApp(Configurable):'
172 exec_files = List(Unicode, config=True,
172 exec_files = List(Unicode, config=True,
173 help="""List of files to run at IPython startup."""
173 help="""List of files to run at IPython startup."""
174 )
174 )
175 exec_PYTHONSTARTUP = Bool(True, config=True,
176 help="""Run the file referenced by the PYTHONSTARTUP environment
177 variable at IPython startup."""
178 )
175 file_to_run = Unicode('', config=True,
179 file_to_run = Unicode('', config=True,
176 help="""A file to be run""")
180 help="""A file to be run""")
177
181
@@ -354,8 +358,9 b' class InteractiveShellApp(Configurable):'
354 """Run files from profile startup directory"""
358 """Run files from profile startup directory"""
355 startup_dir = self.profile_dir.startup_dir
359 startup_dir = self.profile_dir.startup_dir
356 startup_files = []
360 startup_files = []
357 if os.environ.get('PYTHONSTARTUP', False):
361 if self.exec_PYTHONSTARTUP:
358 startup_files.append(os.environ['PYTHONSTARTUP'])
362 if os.environ.get('PYTHONSTARTUP', False):
363 startup_files.append(os.environ['PYTHONSTARTUP'])
359 startup_files += glob.glob(os.path.join(startup_dir, '*.py'))
364 startup_files += glob.glob(os.path.join(startup_dir, '*.py'))
360 startup_files += glob.glob(os.path.join(startup_dir, '*.ipy'))
365 startup_files += glob.glob(os.path.join(startup_dir, '*.ipy'))
361 if not startup_files:
366 if not startup_files:
@@ -761,13 +761,14 b" won't work::"
761 IPython as your default Python environment
761 IPython as your default Python environment
762 ==========================================
762 ==========================================
763
763
764 Python honors the environment variable PYTHONSTARTUP and will execute at
764 Python honors the environment variable :envvar:`PYTHONSTARTUP` and will
765 startup the file referenced by this variable. If you put the following code at
765 execute at startup the file referenced by this variable. If you put the
766 the end of that file, then IPython will be your working environment anytime you
766 following code at the end of that file, then IPython will be your working
767 start Python::
767 environment anytime you start Python::
768
768
769 from IPython.frontend.terminal.ipapp import launch_new_instance
769 import os, IPython
770 launch_new_instance()
770 os.environ['PYTHONSTARTUP'] = '' # Prevent running this again
771 IPython.start_ipython()
771 raise SystemExit
772 raise SystemExit
772
773
773 The ``raise SystemExit`` is needed to exit Python when
774 The ``raise SystemExit`` is needed to exit Python when
General Comments 0
You need to be logged in to leave comments. Login now