.py as executable extension on windows

Discussion in 'Python' started by Achim Domma (Procoders), Sep 15, 2004.

  1. Hi,

    is there a way to tell windows, that *.py files are executable, like
    ..bat, .js, ...? If I have someTool.py somewhere in my path I would like
    to type only 'someTool param1 param2'. Is that possible?

    regards,
    Achim
     
    Achim Domma (Procoders), Sep 15, 2004
    #1
    1. Advertising

  2. Achim Domma (Procoders)

    JanC Guest

    Achim Domma (Procoders) schreef:

    > is there a way to tell windows, that *.py files are executable, like
    > .bat, .js, ...? If I have someTool.py somewhere in my path I would like
    > to type only 'someTool param1 param2'. Is that possible?


    Google for "PATHEXT".

    --
    JanC

    "Be strict when sending and tolerant when receiving."
    RFC 1958 - Architectural Principles of the Internet - section 3.9
     
    JanC, Sep 15, 2004
    #2
    1. Advertising

  3. Achim Domma (Procoders)

    Tim Peters Guest

    [Achim Domma]
    > is there a way to tell windows, that *.py files are executable, like
    > .bat, .js, ...? If I have someTool.py somewhere in my path I would like
    > to type only 'someTool param1 param2'. Is that possible?


    Not on a command.com system (95/98/ME). On a cmd.exe system
    (NT/2K/XP), go to a DOS box and type

    ftype /?

    Skip down to the part explaining PATHEXT.
     
    Tim Peters, Sep 15, 2004
    #3
  4. Achim Domma (Procoders)

    aurora Guest

    Some useful information in Windows faq

    http://www.python.org/doc/faq/windows.html#how-do-i-make-python-scripts-executable


    On Wed, 15 Sep 2004 22:30:33 +0200, Achim Domma (Procoders)
    <> wrote:

    > Hi,
    >
    > is there a way to tell windows, that *.py files are executable, like
    > .bat, .js, ...? If I have someTool.py somewhere in my path I would like
    > to type only 'someTool param1 param2'. Is that possible?
    >
    > regards,
    > Achim
     
    aurora, Sep 15, 2004
    #4
  5. Or try "sometool.py param1 param2"! Works fine for me.

    Stefan

    On 15.09.2004, at 22:54, aurora wrote:

    > Some useful information in Windows faq
    >
    > http://www.python.org/doc/faq/windows.html#how-do-i-make-python-
    > scripts-executable
    >
    >
    > On Wed, 15 Sep 2004 22:30:33 +0200, Achim Domma (Procoders)
    > <> wrote:
    >
    >> Hi,
    >>
    >> is there a way to tell windows, that *.py files are executable, like
    >> .bat, .js, ...? If I have someTool.py somewhere in my path I would
    >> like to type only 'someTool param1 param2'. Is that possible?
    >>
    >> regards,
    >> Achim

    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >
    >
     
    Stefan Eischet, Sep 15, 2004
    #5
  6. On Wed, 15 Sep 2004 16:45:41 -0400, Tim Peters <> wrote:

    >[Achim Domma]
    >> is there a way to tell windows, that *.py files are executable, like
    >> .bat, .js, ...? If I have someTool.py somewhere in my path I would like
    >> to type only 'someTool param1 param2'. Is that possible?

    >
    >Not on a command.com system (95/98/ME). On a cmd.exe system
    >(NT/2K/XP), go to a DOS box and type
    >
    > ftype /?
    >
    >Skip down to the part explaining PATHEXT.


    I'd forgotten where that was explained. Thanks. The OP might also
    want to know that NT/2K/XP is not a guarantee of full satifaction,
    (as you know ;-).

    I.e., note that some versions (e.g. NT4.0) of windows don't do i/o redirection
    properly for output generated by a script invoked via extension association.

    IOW, e.g., someTool param1 param2 > result.txt may give you an empty result.txt.
    Same for piping either input or output. This is not a python problem.
    The same will happen for perl (and super-weird hacks have been attempted
    to work around it IIRC ;-) So if you want to redicrect i/o on such
    windows versions, you will have to run the scripts explicitly as arguments
    to the python interpreter, e.g. python someTool.py param1 param2 > result.txt
    and you will need to specify a full path to someTool.py if you are not in
    the same directory. For stuff you use a lot, you will probably wind up writing
    someTool.cmd (whose ouput will be redirectable) as a one-line invocation of
    python and someTool.py (passing through all cmd line args). E.g.,

    @python c:\pywk\ut\ppcomp2.py %*

    starts a little utility for me, which I invoke as ppcomp -- which runs ppcomp.cmd
    in c:\util -- which is on my session's path for the os's finding executables.

    IIRC there's also a way to rename .py to .cmd and put a tricky first line in
    to fake unix sort of and invoke python to interpret the rest as python, but
    I'm repressing memory of the details ;-)

    I guess newer windows versions don't have this problem so much, but it's worth
    knowing, so you can recognize the symptom when it happens.

    Regards,
    Bengt Richter
     
    Bengt Richter, Sep 15, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand
    Replies:
    3
    Views:
    907
    Tim Daneliuk
    Nov 8, 2003
  2. Replies:
    15
    Views:
    498
    Dave Thompson
    Aug 21, 2006
  3. pratap
    Replies:
    20
    Views:
    774
    Flash Gordon
    Mar 7, 2007
  4. Jason Cavett
    Replies:
    8
    Views:
    635
    Sanjay
    May 16, 2007
  5. Replies:
    0
    Views:
    451
Loading...

Share This Page