The Python window recognizes the system environment variable PYTHONSTARTUP. If PYTHONSTARTUP has been previously set to a Python file, Python will automatically execute that file's code when the Python window is opened. This is a useful way to ensure that your Python window experience starts with all your commonly used Python utilities preloaded.
To add the PYTHONSTARTUP environment setting, do the following:
- Right-click My Computer and click Properties.
- Click the Advanced tab and click Environment Variables.
- Under System variables, click New.
- Add PYTHONSTARTUP to Variable name.
- Add the path of the Python file to Variable value and click OK.
- Click OK.
Below is one possible startup file. If PYTHONPATH has been set to this startup file, when you open the Python window, arcpy, numpy, and time will already be imported, and the overwriteOutput setting will be turned on.
# My startup file import arcpy from arcpy import env import numpy import time env.overwriteOutput = True
Python window context menu
Right-click in the Python window or the Python window help and syntax pane to view the context menu for that section.
Show Default Choices
When checked, code completion will provide available options.
Add To Results
When checked, tools executed in the Python window will be added to the Results window.
Load an existing Python file.
Save Python window contents to a Python or text file.
This describes where the Help pane will be placed, relative to the main prompt.
Change Python window theme and character fonts and colors.