views:

67

answers:

1

64-bit Vista Python 2.6 IPython 0.10 Also have Python 2.7 and 3.1

My ipy_user_conf.py has example lines showing how to set an editor. I've tried

ipy_editors.idle()

but

[C:Python26/Scripts] |4>ed xxx.py Editing... > C:\Python26\lib\idlelib/idle.py "xxx.py"

opens the IDLE for Python 3.1, and doesn't open xxx.py.

I next imitated a sample line in ipy_user_conf.py,

ipy_editors.scite('c:/opt/scite/scite.exe')

as

ipy_editors.idle("c:/Python26/Lib/idlelib/idle.pyw")

but

[C:Python26/Scripts] |4>ed xxx.py Editing... > c:/Python26/Lib/idlelib/idle.pyw "xxx.py"

opens the FILE c:/Python26/Lib/idlelib/idle.pyw in the IDLE for Python 3.1

I've run out of ideas. Advice, please.

BTW run xxx.py works fine.

+1  A: 

The most likely cause is Windows' file name extension associations. I'm guessing Python 3.1 was the last version of python that you installed, so by default, .py and .pyw are now associated with the 3.1 executable. (One way you can verify which python version is associated with the .py/.pyw extensions is to run assoc .py. There are other ways also.)

To get around this, explicitly say which python version you want to run:

ipy_editors.idle('c:/Python26/pythonw.exe c:/Python26/Lib/idlelib/idle.pyw')

Edit:
A pythonic way to test the association would be to create a test.py file such as:

import sys
print sys.version

Then at a command prompt, just run it as test.py.

ma3
Thank you! Thank you! That does it! I've spent the last 20 hours trying to get an answer -- first from the [email protected] list, then from [email protected], and all the while reading the docs and doing much trial and error. BTW where do I do the assoc .py ?
NotSuper
It's a built-in Windows tool. Just run it from a command prompt. [Reference](http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/assoc.mspx)
ma3
Ah, I see. Works for .txt: C:\Windows\System32>assoc .txt.txt=txtfile, but not for .py . And when I get the whole list of associations, .py isn't on it. Hm..
NotSuper
OK. Made the file and ran it. c:\>test_version.py'3.1.2 (r312:79147, Mar 22 2010, 12:30:45) [MSC v.1500 64 bit (AMD64)]' Thanks again!
NotSuper