[Python-Dev] 3.2.1 encoding surprise
Mark Hammond
skippy.hammond at gmail.com
Thu Jul 21 02:34:34 CEST 2011
On 21/07/2011 10:13 AM, Glenn Linderman wrote:
> On 7/20/2011 2:43 PM, Glenn Linderman wrote:
>>> It's not py's job to walk the path: the shell does that when you just type
>>> "foo". It locates foo.py, and then invokes py because of file association - py
>>> then checks the file for a shebang to decide which Python to dispatch it to.
>>
>> Certainly when the launcher is invoked via an association, this would
>> be the case. However, when the launcher is invoked via the command
>> line, then the unqualified name is passed through. To be useful from
>> the command line, the launcher should walk the PATH to find the .py file.
>
> The Windows SearchPath API
> <http://msdn.microsoft.com/en-us/library/aa365527%28v=VS.85%29.aspx>
> makes it a pretty easy job to walk the PATH. Would even allow low cost
> additional feature of searching for both foo and foo.py at the same time.
But that would also require us to parse the command-line, understand
which options require 2 args and which just require 1 (making it fragile
in the face of later versions introducing new options), then
re-stitching a modified command-line back together for the child
process. IMO that is all out of scope.
Are you maybe forgetting about the PATHEXT functionality? If you
include .py in your PATHEXT and file associations are set so .py files
are handled by the launcher, you should be able to directly execute just
'foo' and have the command processor search the PATH for a foo.py and
invoke it via the launcher.
Mark
More information about the Python-Dev
mailing list