hello, *the pep 397 says that any python script is able to choose the language version which will run it, between all the versions installed on the computer, using on windows a launcher in the "C:\windows" folder.* can the idle version be chosen like this too, or can the idle "run" command do it? (except it is already like this and I have a problem) thank you, and have a nice day/evening! (and sorry if this sounds irritating)
On Wed, Dec 31, 2014 at 7:31 AM, Liam Marsh <liam.marsh.home@gmail.com> wrote:
the pep 397 says that any python script is able to choose the language version which will run it, between all the versions installed on the computer, using on windows a launcher in the "C:\windows" folder.
can the idle version be chosen like this too, or can the idle "run" command do it?
I don't know of a way off-hand. However, if the information is already there in the shebang (as per PEP 397), it ought to be possible to rig up a launcher/chooser script. This might be something to discuss on python-list@python.org, rather than here; there are a lot more people on python-list than there are here on -ideas, and I suspect you don't need any changes to the language to make this work. It's also entirely possible that someone there already knows exactly what you need to do! ChrisA
"I suspect you don't need any changes to the language to make this work" - you are right, this problem does not affect the language itself, but the idlelib library.... - I was thinking of an "pyidle" executable next to the "py" and "pyw" executables. I am also trying to create a small script to do this... 2014-12-30 23:38 GMT+01:00 Chris Angelico <rosuav@gmail.com>:
On Wed, Dec 31, 2014 at 7:31 AM, Liam Marsh <liam.marsh.home@gmail.com> wrote:
the pep 397 says that any python script is able to choose the language version which will run it, between all the versions installed on the computer, using on windows a launcher in the "C:\windows" folder.
can the idle version be chosen like this too, or can the idle "run" command do it?
I don't know of a way off-hand. However, if the information is already there in the shebang (as per PEP 397), it ought to be possible to rig up a launcher/chooser script. This might be something to discuss on python-list@python.org, rather than here; there are a lot more people on python-list than there are here on -ideas, and I suspect you don't need any changes to the language to make this work.
It's also entirely possible that someone there already knows exactly what you need to do!
ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
On Thu, Jan 1, 2015 at 11:47 PM, Liam Marsh <liam.marsh.home@gmail.com> wrote:
"I suspect you don't need any changes to the language to make this work"
- you are right, this problem does not affect the language itself, but the idlelib library.... - I was thinking of an "pyidle" executable next to the "py" and "pyw" executables. I am also trying to create a small script to do this...
A small script ought to be able to handle it. All it needs to do is: 1) Read in the first line of the file. 2) See if it can be parsed according to PEP 397 3) Invoke IDLE. Since this is primarily for your own personal use, rather than being a part of the language or standard library, you could make a few assumptions - for instance, assume an ASCII-compatible file encoding, assume that it won't get any arguments other than the script to open, anything else that'll make your life easier. Knock something together, and if you have trouble with the details, python-list will undoubtedly be willing to help out. All the best! ChrisA
On 01.01.2015 14:27, Chris Angelico wrote:
On Thu, Jan 1, 2015 at 11:47 PM, Liam Marsh <liam.marsh.home@gmail.com> wrote:
"I suspect you don't need any changes to the language to make this work"
- you are right, this problem does not affect the language itself, but the idlelib library.... - I was thinking of an "pyidle" executable next to the "py" and "pyw" executables. I am also trying to create a small script to do this...
A small script ought to be able to handle it. All it needs to do is:
1) Read in the first line of the file. 2) See if it can be parsed according to PEP 397 3) Invoke IDLE.
Yes and no. It is certainly doable, but it also means coding things twice since the functionality already exists in the launcher. What would be good is if the launcher had an additional flag telling it to not actually start python, but just report the path to it, something like: $ py --dry-run my_script C:\Python34\python.exe
On Fri, Jan 16, 2015 at 1:31 AM, Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> wrote:
What would be good is if the launcher had an additional flag telling it to not actually start python, but just report the path to it, something like:
$ py --dry-run my_script
C:\Python34\python.exe
Ooh that would be a nice feature. I'd be inclined to call it --query rather than --dry-run, but that's just bike-shedding. Any other programs could make use of this feature too - maybe they want to run a wrapper that ultimately invokes some script, so the wrapper gets written to be 2.7 and 3.3+ compatible, and then design it to be run using the target script's interpreter. ChrisA
On 15.01.2015 15:47, Chris Angelico wrote:
On Fri, Jan 16, 2015 at 1:31 AM, Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> wrote:
What would be good is if the launcher had an additional flag telling it to not actually start python, but just report the path to it, something like:
$ py --dry-run my_script
C:\Python34\python.exe
Ooh that would be a nice feature. I'd be inclined to call it --query rather than --dry-run, but that's just bike-shedding. Any other programs could make use of this feature too - maybe they want to run a wrapper that ultimately invokes some script, so the wrapper gets written to be 2.7 and 3.3+ compatible, and then design it to be run using the target script's interpreter.
Right, that was what I was thinking of, too.
On Fri, Jan 16, 2015 at 01:47:46AM +1100, Chris Angelico wrote:
On Fri, Jan 16, 2015 at 1:31 AM, Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> wrote:
What would be good is if the launcher had an additional flag telling it to not actually start python, but just report the path to it, something like:
$ py --dry-run my_script
C:\Python34\python.exe
Ooh that would be a nice feature. I'd be inclined to call it --query rather than --dry-run, but that's just bike-shedding.
Sometimes bike-shedding has a bad reputation. Option names should reflect what they do. --dry-run suggests that it will run the script except for anything destructive (e.g. writing or deleting files, printing a 300 page report). --query is better, but query what? This isn't a common command that needs to be short even at the expense of being cryptic, so how about a self-documenting switch like: --which-executable --which-python and -w for those who insist on having short cryptic switches :-) -- Steven
On Fri, Jan 16, 2015 at 2:54 AM, Steven D'Aprano <steve@pearwood.info> wrote:
Ooh that would be a nice feature. I'd be inclined to call it --query rather than --dry-run, but that's just bike-shedding.
Sometimes bike-shedding has a bad reputation. Option names should reflect what they do. --dry-run suggests that it will run the script except for anything destructive (e.g. writing or deleting files, printing a 300 page report). --query is better, but query what?
"Just" bike-shedding means that I support the feature, and think it's a great idea, but all it needs is a different name. And you're right, --which-executable would be better than --query. ChrisA
On Thu, Jan 15, 2015 at 8:31 AM, Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> wrote:
What would be good is if the launcher had an additional flag telling it to not actually start python, but just report the path to it, something like:
$ py --dry-run my_script
C:\Python34\python.exe
How about: % python -c 'import sys ; print sys.executable' /opt/local/bin/python ? Skip
On Fri, Jan 16, 2015 at 1:52 AM, Skip Montanaro <skip.montanaro@gmail.com> wrote:
On Thu, Jan 15, 2015 at 8:31 AM, Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> wrote:
What would be good is if the launcher had an additional flag telling it to not actually start python, but just report the path to it, something like:
$ py --dry-run my_script
C:\Python34\python.exe
How about:
% python -c 'import sys ; print sys.executable' /opt/local/bin/python
It has to be able to be controlled by a shebang in the script itself. ChrisA
On 15.01.2015 15:52, Skip Montanaro wrote:
On Thu, Jan 15, 2015 at 8:31 AM, Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> wrote:
What would be good is if the launcher had an additional flag telling it to not actually start python, but just report the path to it, something like:
$ py --dry-run my_script
C:\Python34\python.exe
How about:
% python -c 'import sys ; print sys.executable' /opt/local/bin/python
?
What is of interest here is not what is hiding behind "python". It is about finding out which python would have been selected by the Python launcher based on the shebang line of the script. Wolfgang
On 12/30/2014 3:31 PM, Liam Marsh wrote:
/the pep 397 says that any python script is able to choose the language version which will run it, between all the versions installed on the computer, using on windows a launcher in the "C:\windows" folder./
can the idle version be chosen like this too, or can the idle "run" command do it?
Question about using python, including Idle, should be directed to python-list. Quick answers to what seem to be separate questions. 1. At the command line, one select the version of a module to run by selecting the version of python to run. Idle is no different from any other module intended to be directly run. For me, C:\Users\Terry>py -2 -m idlelib.idle # starts Idle in 2.7.9 C:\Users\Terry>py -3 -m idlelib # starts Idle in 3.4.2 On Windows, I pin the Start -> Pythonx.y -> Idle x.y icons to my task bar so I can select either python + idle combination with a mouse click. 2. Selecting F5 or Run-module in an Idle editor runs the editor buffer contents with the same version of python as is running Idle. I have considered adding 'Run with x.y' options according to what is installed, but that is pie-in-the-sky at the moment. -- Terry Jan Reedy
"On Windows, I pin the Start -> Pythonx.y -> Idle x.y icons to my task bar so I can select either python + idle combination with a mouse click." yes, but this doesn't fix the "right click -> edit with idle" problem (maybe calling "py.exe --edit <file>" instead of "idle.bat <file>" on windows will fix it) 2015-01-17 2:45 GMT+01:00 Terry Reedy <tjreedy@udel.edu>:
On 12/30/2014 3:31 PM, Liam Marsh wrote:
/the pep 397 says that any python script is able to choose the language
version which will run it, between all the versions installed on the computer, using on windows a launcher in the "C:\windows" folder./
can the idle version be chosen like this too, or can the idle "run" command do it?
Question about using python, including Idle, should be directed to python-list. Quick answers to what seem to be separate questions.
1. At the command line, one select the version of a module to run by selecting the version of python to run. Idle is no different from any other module intended to be directly run. For me,
C:\Users\Terry>py -2 -m idlelib.idle # starts Idle in 2.7.9
C:\Users\Terry>py -3 -m idlelib # starts Idle in 3.4.2
On Windows, I pin the Start -> Pythonx.y -> Idle x.y icons to my task bar so I can select either python + idle combination with a mouse click.
2. Selecting F5 or Run-module in an Idle editor runs the editor buffer contents with the same version of python as is running Idle. I have considered adding 'Run with x.y' options according to what is installed, but that is pie-in-the-sky at the moment.
-- Terry Jan Reedy
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
On 2/22/2015 12:36 PM, Liam Marsh wrote:
"On Windows, I pin the Start -> Pythonx.y -> Idle x.y icons to my task bar so I can select either python + idle combination with a mouse click." yes, but this doesn't fix the "right click -> edit with idle" problem
As far as I know, that may be a Windows-only feature. In any case, it is an installation feature, not a Python feature. (You could potentially change it yourself.) Feel free to open an issue on the tracker to change the Windows installer to install 'Edit with Idle x.y' for each Python version installed and add steve.dower as nosy. -- Terry Jan Reedy
participants (6)
-
Chris Angelico -
Liam Marsh -
Skip Montanaro -
Steven D'Aprano -
Terry Reedy -
Wolfgang Maier