Re: [Python-Dev] PEP397 no command line options to python?
(Sorry, should have gone to the list...)
On 22 October 2011 13:15, Vinay Sajip
Nick Coghlan
writes: As a simpler alternative, I suggest the launcher just gain a "--which" long option that displays the full path to the interpreter it found.
So:
C:\> py -2 --which C:\Python27\python.exe
C:\> py -3 --which C:\Python32\python.exe
No significant complexity in the launcher, and if you want to add additional arguments like -m, -c, or -i you can do it by running '--which' and switching to invoking that interpreter directly.
Perhaps even simpler would be for the -h option to print the interpreter paths which would be returned for -2 and -3, on separate lines, even without the --which, e.g.
Currently configured: -2: c:\Python27\python.exe -3: c:\Python32\python.exe
--which is nice for people who can use Unix-style $() or Powershell & to directly execute the output as a command. & (py -3 --which) Paul
On 23/10/2011 12:27 AM, Paul Moore wrote:
(Sorry, should have gone to the list...)
On 22 October 2011 13:15, Vinay Sajip
wrote: Nick Coghlan
writes: As a simpler alternative, I suggest the launcher just gain a "--which" long option that displays the full path to the interpreter it found.
So:
C:\> py -2 --which C:\Python27\python.exe
C:\> py -3 --which C:\Python32\python.exe
No significant complexity in the launcher, and if you want to add additional arguments like -m, -c, or -i you can do it by running '--which' and switching to invoking that interpreter directly.
Perhaps even simpler would be for the -h option to print the interpreter paths which would be returned for -2 and -3, on separate lines, even without the --which, e.g.
Currently configured: -2: c:\Python27\python.exe -3: c:\Python32\python.exe
--which is nice for people who can use Unix-style $() or Powershell& to directly execute the output as a command.
& (py -3 --which)
How about abusing the existing flags for this purpose - eg: % py -3? % py -2.7? etc. Mark
On Mon, Oct 24, 2011 at 8:15 AM, Mark Hammond
How about abusing the existing flags for this purpose - eg:
% py -3? % py -2.7?
What does using the magic symbol offer over an explicit separate flag? Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
On 24/10/2011 10:36 AM, Nick Coghlan wrote:
On Mon, Oct 24, 2011 at 8:15 AM, Mark Hammond
wrote: How about abusing the existing flags for this purpose - eg:
% py -3? % py -2.7?
What does using the magic symbol offer over an explicit separate flag?
* The "magic" symbol is somewhat self-documenting - it implies a question. Using --which adds another special case that people would need to understand isn't passed to Python. IOW, I like that there is only 1 special option and that one special option can be expressed in the form of a question. * Simplicity - does "py -2.3 --which" work the same as "py --which -2.3"? If not, that's not at all intuitive. If so, it adds complexity to the launcher and the PEP text. * Extensibility - While I've resisted, I predict that due to popular demand, we will wind up supporting additional arguments which are passed directly to Python (eg, "py -2.3 -W scriptName"). If we did, how would we treat --which when it is specified with additional options? So to turn the question back around - why introduce a new special option when the existing single special option can be leveraged? Are we opening the door to further special options? I guess the key downside to this suggestion is that it doesn't allow you ask where the default Python is without using "-2?" (or maybe just -?) Mark
On Mon, Oct 24, 2011 at 10:00 AM, Mark Hammond
* The "magic" symbol is somewhat self-documenting - it implies a question. Using --which adds another special case that people would need to understand isn't passed to Python. IOW, I like that there is only 1 special option and that one special option can be expressed in the form of a question.
This may be a difference in what we're used to. To me, the "-?" is strongly associated with "-h" and "--help", whereas "--which" maps directly to the *nix "which" command: $ which python /usr/bin/python As far as simplicity and extensibility go, I would treat "--which" the way most programs treat "--help" and "--version" - they can appear anywhere on the command line and completely change the expected output of the command: $ python -Ei --version -c "This is never evaluated" Python 2.7.1 So I don't actually see any particularly *new* design decisions to be made in relation to a "--which" option - it's just a workaround for the lack of a native 'which' equivalent on Windows, and it behaves like Python's own "--version" option. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
On 24/10/2011 11:46 AM, Nick Coghlan wrote:
On Mon, Oct 24, 2011 at 10:00 AM, Mark Hammond
wrote: * The "magic" symbol is somewhat self-documenting - it implies a question. Using --which adds another special case that people would need to understand isn't passed to Python. IOW, I like that there is only 1 special option and that one special option can be expressed in the form of a question.
This may be a difference in what we're used to. To me, the "-?" is strongly associated with "-h" and "--help"
Fair enough - and I admit to thinking -? didn't work for Python - but it does!
, whereas "--which" maps directly to the *nix "which" command:
Sure, but this isn't for *nix, so I'm not sure it is safe to assume the users of the launcher will make that association.
So I don't actually see any particularly *new* design decisions to be made in relation to a "--which" option - it's just a workaround for the lack of a native 'which' equivalent on Windows,
Actually I don't think that is true - even with a 'which' on Windows you can't get this information from it. Indeed, this functionality is quite distinct from that offered by which. TBH I'm not that bothered - I just have a slight uneasiness to this new special option which really just helps describe what a different special option does. So - in an effort to talk myself out of my idea... :) one advantage --which would have is that it could work without any version qualifiers at all - eg: % py --which path/to/script.py could also tell you what version of Python would be used to execute the named script, taking into account the current defaults, environment variables and shebang line found in the script. Cheers, Mark
On Mon, Oct 24, 2011 at 11:15 AM, Mark Hammond
So I don't actually see any particularly *new* design decisions to be made in relation to a "--which" option - it's just a workaround for the lack of a native 'which' equivalent on Windows,
Actually I don't think that is true - even with a 'which' on Windows you can't get this information from it. Indeed, this functionality is quite distinct from that offered by which.
True, that comparison was a bad one - the launcher takes into account more than just path entries the way the *nix equivalent does. Still, it's a tool in the same spirit, even if the mechanics differs.
TBH I'm not that bothered - I just have a slight uneasiness to this new special option which really just helps describe what a different special option does.
So - in an effort to talk myself out of my idea... :) one advantage --which would have is that it could work without any version qualifiers at all - eg:
% py --which path/to/script.py
could also tell you what version of Python would be used to execute the named script, taking into account the current defaults, environment variables and shebang line found in the script.
I was actually just thinking of the simple "py --which" use case, but you're right, it could be extended to shebang line checking as well. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
On Sun, Oct 23, 2011 at 17:15, Mark Hammond
How about abusing the existing flags for this purpose - eg:
% py -3? % py -2.7?
I would have expected that to launch an interactive python shell of the appropriate version. Does it do something else today? Michael
On 24/10/2011 12:56 PM, Michael Urman wrote:
On Sun, Oct 23, 2011 at 17:15, Mark Hammond
wrote: How about abusing the existing flags for this purpose - eg:
% py -3? % py -2.7?
I would have expected that to launch an interactive python shell of the appropriate version. Does it do something else today?
That is what it does today without the trailing '?' character. My idea was to allow the trailing '?' to behave like the proposed --which. Mark
On Sun, Oct 23, 2011 at 20:58, Mark Hammond
On 24/10/2011 12:56 PM, Michael Urman wrote:
On Sun, Oct 23, 2011 at 17:15, Mark Hammond
wrote: How about abusing the existing flags for this purpose - eg:
% py -3? % py -2.7?
I would have expected that to launch an interactive python shell of the appropriate version. Does it do something else today?
That is what it does today without the trailing '?' character. My idea was to allow the trailing '?' to behave like the proposed --which.
Oh, I read right over question mark without seeing it. I wonder if that's a notch against it from a documentation standpoint or just my own personal quirk. (I'm not used to thinking of it as a command line flag, partly due to my unix years.) Thanks for explaining!
participants (5)
-
Mark Hammond
-
Mark Hammond
-
Michael Urman
-
Nick Coghlan
-
Paul Moore