You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add IDLE config option for sys.path additions #106786
I work quite a bit with new users running IDLE in Windows.
These users typically do not have the skill to edit Windows environment variables, nor do they typically know how to create a desktop shortcut and then edit its startup directory property.
The startup directory problem is especially irritating because by default IDLE starts up in a hidden path. So any locally created .py files can't easily be found using Windows Explorer. If the users do save new .py files to a new folder on their Desktop, then then can't easily import the files they just made. This makes it difficult when teaching how to import their own modules. This issue can be solved letting IDLE's config specify a startup directory much like MS Word does.
The environment variable issue is also a problem because they often need a temporary PYTHONPATH to point to temporary project directory (which is a typical need in a classroom setting, one directory for instructor provided code and another for their own experiments). This issue can be easily fixed by letting the IDLE configuration have an option for attaching project directories. This could be done by directly manipulating sys.path or by editting the process's PYTHONPATH environment variable (much likeRun ... Customized does for command-line arguments).
changed the title [-]Add IDLE config options for a startup directory and for sys.path additions[/-][+]Add IDLE config option for sys.path additions[/+]on Jul 16, 2023
The startup directory is #72961, which you opened. At the time, you asked me to let a student of yours work on it. Never happened. I won't wait any longer.
Note: IDLE issues, including some drafts (and I have more to add) are now gathered together in a project. The filter bar initially has -status:Done . Adding dire reveals the earlier issue. (startup does not work well because it is a category name.)
Filtering on 'path' does not show any previous issues. I have two problems with a sys.path setting. First, a user might switch within a session between, say, a personal file and a class file that need different settings. Second, it violates the idea that user code should run the same (as nearly as possible) from an editor and a command line. Code that runs in IDLE but not from a command line without obvious reason generates user reports. For example, import tkinter; tkinter.font once ran in IDLE until, prompted by 3 SO questions, I fixed it.
Temporarily manipulating PYTHONPATH has the same issue. To me, it seem meant for situations where all programs on a machine, possibly with multiple should have direct access to machine global local directories for a substantial period of time.
To me, the best solution is to put sys.path.append('appropriate/local/dir') (or extend in each file that needs it. If multiple files need the same boilerplate, I have used template files.
This points to a need for an IDLE howto directed as students and beginners. I have some tips that do not belong in the reference, and I suspect you some too, perhaps even more. Dealing with 'other' local directories would be one of them. I have also thought of looking at some of the videos on Youtube and blogs on the web for more ideas. On Stackoverflow, perhaps the most frequent python question (50?) arises from not understanding the need to pip install packages for each python binary.
Activity
[-]Add IDLE config options for a startup directory and for sys.path additions[/-][+]Add IDLE config option for sys.path additions[/+]terryjreedy commentedon Jul 16, 2023
The startup directory is #72961, which you opened. At the time, you asked me to let a student of yours work on it. Never happened. I won't wait any longer.
Note: IDLE issues, including some drafts (and I have more to add) are now gathered together in a project. The filter bar initially has
-status:Done. Addingdirereveals the earlier issue. (startupdoes not work well because it is a category name.)Filtering on 'path' does not show any previous issues. I have two problems with a sys.path setting. First, a user might switch within a session between, say, a personal file and a class file that need different settings. Second, it violates the idea that user code should run the same (as nearly as possible) from an editor and a command line. Code that runs in IDLE but not from a command line without obvious reason generates user reports. For example,
import tkinter; tkinter.fontonce ran in IDLE until, prompted by 3 SO questions, I fixed it.Temporarily manipulating PYTHONPATH has the same issue. To me, it seem meant for situations where all programs on a machine, possibly with multiple should have direct access to machine global local directories for a substantial period of time.
To me, the best solution is to put
sys.path.append('appropriate/local/dir')(orextendin each file that needs it. If multiple files need the same boilerplate, I have used template files.This points to a need for an IDLE howto directed as students and beginners. I have some tips that do not belong in the reference, and I suspect you some too, perhaps even more. Dealing with 'other' local directories would be one of them. I have also thought of looking at some of the videos on Youtube and blogs on the web for more ideas. On Stackoverflow, perhaps the most frequent python question (50?) arises from not understanding the need to pip install packages for each python binary.