where is it

eryk sun eryksun at gmail.com
Sun Aug 7 02:23:49 EDT 2016


On Sat, Aug 6, 2016 at 5:16 PM, Dave via Python-list
<python-list at python.org> wrote:
> I am trying to associate the .py file extension with idle.......where IS idle?  Can you
> make it a bit more difficult to load/use your software please.

You can run IDLE from the command-line as follows:

    3.x:    python[3][w] -m idlelib [script_path]
    2.x:    python[w] -m idlelib.idle [script_path]

This should work on all supported platforms. If you omit the script
path, it starts an interactive shell. On Windows, pythonw.exe (or
pyw.exe) runs without an attached console.

For Windows, the installer should have set up a right-click
context-menu command to edit .py and .pyw files with IDLE. You can
also use this command in a script via os.startfile. However, the way
it's set up to create a cascaded menu is inconvenient, i.e. the
command for IDLE 3.5 is "editwithidle\shell\edit35". You can copy this
as a default "edit" command for .py and .pyw files. This isn't too
hard to do in PowerShell. For example, if Python 3.5 is installed for
all users (otherwise replace HKLM with HKCU):

    $base = "HKLM:\Software\Classes"
    foreach ($p in ((".py",  "Python.File"),
                    (".pyw", "Python.NoConFile"))) {
        $src = "$base\{0}\Shell\editwithidle\shell\edit35" -f $p[1]
        $dst = "$base\SystemFileAssociations\{0}\Shell" -f $p[0]
        # only set an "edit" command if the source key exists
        # and the default isn't already defined.
        if ((test-path $src) -and
            (-not (test-path $dst\edit))) {
            if (-not (test-path $dst)) {
                new-item -force $dst
            }
            copy-item -recurse $src $dst\edit
        }
    }

The Windows shell looks in HKCR\SystemFileAssociations for default
file associations. The user's selected file type (e.g. Python.File)
can override this key by defining its own "edit" command.



More information about the Python-list mailing list