Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > making a python program in windows

Reply
Thread Tools

making a python program in windows

 
 
Rustom Mody
Guest
Posts: n/a
 
      05-21-2009
I know how to make a python script behave like a (standalone) program
in unix --
1. put a #! path/to/python as the first line
2. make the file executable

The closest I know how to do this in windows is:
r-click the file in win-explorer
goto properties
goto open with
change pythonw to python

Can someone enlighten me about a more scriptish way of doing this?
Basically if I have to setup that program on other (windows) m/cs is
there some .bat or .vbs or some regedit thingy Ive to do to avoid the
Rt-click routine?
 
Reply With Quote
 
 
 
 
rustom
Guest
Posts: n/a
 
      05-21-2009
On May 21, 3:19*pm, "Martin P. Hellwig" <(E-Mail Removed)>
wrote:
> Rustom Mody wrote:
> > I know how to make a python script behave like a (standalone) program
> > in unix --
> > 1. put a #! path/to/python as the first line
> > 2. make the file executable

>
> > The closest I know how to do this in windows is:
> > r-click the file in win-explorer
> > goto properties
> > goto open with
> > change pythonw to python

>
> > Can someone enlighten me about a more scriptish way of doing this?
> > Basically if I have to setup that program on other (windows) m/cs is
> > there some .bat or .vbs or some regedit thingy Ive to do to avoid the
> > Rt-click routine?

>
> Since you don't know for sure if a Python environment is available on
> the other windows machine and whether the file associations are
> configured correctly, the best thing you can do is to use something like
> py2exe and distribute the result of that.


Oh - Oh! Not an exe please! I dont want to move away from readable
text files if possible.

I certainly know that python2.6 is installed.
Why that installation by default does not put python.exe on the path I
dont know but that is best corrected by hand.

Bottom Line: Assume that from a command line (cmd) python runs and
gives its interpreter prompt.
When run from cygwin it hangs but thats another story. Just dont
assume cygwin.

i suppose the question is entirely about setting properly (and
grokking) file associations -- why is a .py file associated with
pythonw and not python? And is making this association right enough to
make a .py file in windows behave like a shebang file in unix?

[And is there a more appropriate list for such questions?]

Thanks
 
Reply With Quote
 
 
 
 
rustom
Guest
Posts: n/a
 
      05-22-2009
On May 21, 5:09*pm, Duncan Booth <(E-Mail Removed)> wrote:
> rustom <(E-Mail Removed)> wrote:
> > i suppose the question is entirely about setting properly (and
> > grokking) file associations -- why is a .py file associated with
> > pythonw and not python? And is making this association right enough to
> > make a .py file in windows behave like a shebang file in unix?

>
> I think the question about the file association is one you have to answer
> for yourself. When you install Python it associates .pyw with pythonw and
> .py with python. If something on your system has changed this the best
> thing you can do is to change it back.
>
> Try typing the following commands and then fixing any differences by typing
> the expected output as the command parameter
> (e.g. "assoc .py=Python.File"):
>
> C:\>assoc .py
> .py=Python.File
>
> C:\>assoc .pyw
> .pyw=Python.NoConFile
>
> C:\>ftype Python.file
> Python.file="C:\Python26\python.exe" "%1" %*
>
> C:\>ftype Python.NoConFile
> Python.NoConFile="C:\Python26\pythonw.exe" "%1" %*
>
> --
> Duncan Boothhttp://kupuguy.blogspot.com


Thanks for this (and all other) tips.
Strangely now my m/c shows things exactly like so. A new .py file gets
associated with python but two days ago it was with pythonw?!
Any recos on where I could read up on this stuff?
 
Reply With Quote
 
Tim Golden
Guest
Posts: n/a
 
      05-22-2009
rustom wrote:
> Thanks for this (and all other) tips.
> Strangely now my m/c shows things exactly like so. A new .py file gets
> associated with python but two days ago it was with pythonw?!
> Any recos on where I could read up on this stuff?


I by "all this stuff" you mean: Windows file associations,
then this would be the place:

http://msdn.microsoft.com/en-us/libr...90(VS.85).aspx

If you mean: what the Python installer does to set such
things up, then there is some information here:

http://docs.python.org/using/windows.html

but not really covering the exact question you've
been asking. You'd have to hunt around the archives
of this mailing list and/or look at the msi source:

http://svn.python.org/view/python/tr...py?view=markup

(and feel free to submit a doc patch if you think it might help)

TJG
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making ActivePython and Python co-exist on Windows CWC Python 3 11-08-2010 06:30 PM
How to get inputs for a python program that run from another python program pradeep nair Python 2 06-12-2007 01:20 PM
Re: A fresh new approach to making making online Fakename Computer Information 0 11-18-2005 02:10 AM
Making new Flavors : Making a custom transferhandler for and drop applications ebby83@gmail.com Java 5 01-12-2005 11:10 AM
Re: [Python-Dev] Making python C-API thread safe (try 2) Shane Hathaway Python 3 09-12-2003 05:50 AM



Advertisments