Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49170 > unrolled thread

Re: Inconsistency on getting arguments

Started byChris Angelico <rosuav@gmail.com>
First post2013-06-26 02:03 +1000
Last post2013-06-26 02:03 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Inconsistency on getting arguments Chris Angelico <rosuav@gmail.com> - 2013-06-26 02:03 +1000

#49170 — Re: Inconsistency on getting arguments

FromChris Angelico <rosuav@gmail.com>
Date2013-06-26 02:03 +1000
SubjectRe: Inconsistency on getting arguments
Message-ID<mailman.3836.1372176697.3114.python-list@python.org>
On Wed, Jun 26, 2013 at 12:17 AM, Dave Angel <davea@davea.name> wrote:
> On 06/25/2013 09:55 AM, Peter Otten wrote:
>>
>> Marco Perniciaro wrote:
>>
>>> Hi,
>>> I've been working with Python for a long time.
>>> Yet, I came across an issue which I cannot explain.
>>>
>>> Recently I have a new PC (Windows 7).
>>> Previously I could call a Python script with or without the "python" word
>>> at the beginning. Now the behavior is different if I use or not use the
>>> "python" prefix!
>>>
>>> I only have Python 2.7 installed and the path in in my environment
>>> variable. I create a simple file called "example.py" which contains two
>>> lines:
>>>
>>>        import sys
>>>        print sys.argv
>>>
>>> This is the output result:
>>>
>>>        C:\Users\mapr>example.py a b c
>>>        ['C:\\Users\\mapr\\example.py']
>>>
>>>        C:\Users\mapr>python example.py a b c
>>>        ['example.py', 'a', 'b', 'c']
>>>
>>> Can someone please explain?
>>
>>
>> I'm not a Windows user, but I'd try
>>
>> http://docs.python.org/2/using/windows.html#executing-scripts
>>
>> with python.exe instead of pythonw.exe. Maybe the %* is missing.
>>
>
> I'm not a Windows user either (at least for quite a while).  But I'd
> investigate with assoc and ftype and see that the ftype includes the
> trailing %* parameter.  Do not mess with .pyw and  pythonw, as they are both
> for GUI programs, and you're doing a console program.
>
> I think if you type ftype it'll list them all.  So if you grep that, you
> should be able to find the line for  Python.File   And yeah, you can
> probably tell ftype to just display that line, but I don't have a system to
> try it on, or even to use /? on, so I'm not going to issue unsafe advice.

I do have access to a system to test this on, so here's the results:

C:\>assoc .py
.py=Python.File

C:\>ftype Python.File
Python.File="C:\Python27\python.exe" "%1" %*

As I understand it, the first command will tell you the name that you
need for the second command, and the second one will tell you what
actually gets executed. I have several Pythons installed on this
particular computer, apparently with 2.7 being the default (not that I
care; I usually invoke "\python33\python script.py" or similar to
choose my interpreter). Hope that's of value!

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web