Re-opening saved files

When I save a file while working in IDLE and go back to edit or make comments, it doesn’t open. I get a black window that flashes on my screen and nothing more happens. I am using this program for school and when the professor sends us examples I cannot open his examples and the same black window flashes.

I am new to Python so I could be doing something wrong but I have tried everything I can think of and have tried to look up my problem and no real solutions.

Thank you for your help!

Without knowing what you are doing, we have to guess what you are doing.

How exactly are you trying to open the files?

  • double-clicking?
  • right-click then choose something?
  • something else?

What operating system are you using? Linux, Mac, Windows, something else?

Have you tried showing your classmates or your tutor and see what they say?

Sorry for no specifics I wasn’t sure how to explain my exact problem. I am using Windows operating system. When I open the file, I have tried double clicking, I have tried to right click and chose open with Python I have tried to open it with any option available. One thing I noticed while looking up my problem is other people receive the option to edit their python files but that does not show up for me and I don’t know how to get the option to show up.

I have tried to reach out to classmates or my professor, but they are not getting back to me. I will try to ask a tutor for help I just thought I’d see if anyone has any answers here.

Thank you for your time!

Are you getting a security notification when you write the file? Occasionally I get this with another editor. IDLE may not be able to read the file because it is quarantined. You can click the notification to get to a settings panel where you can allow the write to the file’s folder.

Just to be sure we are not missing something. Did you also try to start IDLE and open the file from the menu there?

image

Does it fail too? If so, how exactly does it fail?

1 Like

Try using the File > Open menu from inside IDLE.

Somebody more experienced with Windows than me might be able to suggest how to associate .py files with IDLE so that double-clicking opens then in IDLE instead of running them in a terminal.

1 Like

Steven: I believe you cracked this one. :+1:
Kayla:
Right-Click your ~.py program file.
This menu will appear:

When you click “Open with”, you should see this:

image

When this question appears, set the “Always use this app…” option and click " More Apps ↓ " and scroll down the list until you find your editor (IDLE). If IDLE is not on the list and you arrive at the bottom (IDLE probably will not be on the list), you will have to then click “Look for another app on this PC”
image

and…

  1. …browse to your Python installation.
  2. …enter the directory (“folder”) named ‘Lib
  3. …enter the directory named ‘idlelib’.
  4. …Click *idle.bat and then click [ Open ]  (or Double-Click idle.bat).

Your program will open in IDLE and you should now be able to Double-Click any ~.py file to open it in IDLE.

THIS WEB PAGE has a different approach (using the file properties dialogue box) plus some extra help with finding your Python installation.

If you installed from python.org and do not see the “Edit with IDLE” submenu on the file context menu (possibly behind a “show more options” command), then re-associate .py files with the “Python” launcher app, which has a Python icon with a rocket on it.

This associates .py files with the “Python.File” programmatic identifier (progid). When a .py file is double clicked or run directly from the command line, the default action of the Python.File progid is to “open” the file, which executes it via the “py.exe” launcher.

You can modify the registry to change the default action to one of the IDLE edit actions. In regedit, if “HKCU\Software\Classes\Python.File\Shell” doesn’t exist already, create it. Change the default value of this key to reference one of the IDLE edit actions, e.g. setting it to “editwithidle\shell\edit310” opens the file in Python 3.10 IDLE. For Python versions that are installed for the current user, the available IDLE edit actions will be defined as subkeys of “HKCU\Software\Classes\Python.File\Shell”. For versions installed for all users, check in “HKLM\Software\Classes\Python.File\Shell”. Either way, the default action set for the current user is what the shell uses. (The GUI shell really needs a default action picker to make this easier to modify.)