Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > #! Question

Reply
Thread Tools

#! Question

 
 
Ian Pellew
Guest
Posts: n/a
 
      02-20-2004
Hi All;

How do I get line one to call python:-
This is line one in my python script
#!C:/Program Files/Python2.3.3/python.exe

gives:-
Win32_Prompt> "C:\Documents and Settings\ipellew\My Documents\gt.py"
c:\Progra~1\Python2.3.3\python.exe: can't open file './C:\Documents
and Settings\ipellew\My Documents\gt.py'

my python script is in:-
"C:\Documents and Settings\ipellew\My Documents"

Regards
Ian
 
Reply With Quote
 
 
 
 
omission9
Guest
Posts: n/a
 
      02-20-2004
Ian Pellew wrote:
> Hi All;
>
> How do I get line one to call python:-
> This is line one in my python script
> #!C:/Program Files/Python2.3.3/python.exe
>
> gives:-
> Win32_Prompt> "C:\Documents and Settings\ipellew\My Documents\gt.py"
> c:\Progra~1\Python2.3.3\python.exe: can't open file './C:\Documents
> and Settings\ipellew\My Documents\gt.py'
>
> my python script is in:-
> "C:\Documents and Settings\ipellew\My Documents"
>
> Regards
> Ian

You should have python.exe in you path. In any event, the space in
"Program Files" is sure to cause trouble. Put anything with spaces
inside double quotes.
#!"C:/Program Files/Python2.3.3/python.exe" will work.

 
Reply With Quote
 
 
 
 
Josiah Carlson
Guest
Posts: n/a
 
      02-20-2004
> You should have python.exe in you path. In any event, the space in
> "Program Files" is sure to cause trouble. Put anything with spaces
> inside double quotes.
> #!"C:/Program Files/Python2.3.3/python.exe" will work.


Not on windows. On windows, no amount of #! trickery will get you
anywhere (unless you are using bash, sh, etc. in windows via cygwin).
For good or evil, windows uses file-extension associations. That is, in
order to be able to open a file that is not an executable, shortcut, or
batch file (exe, com, scr, pif, lnk, bat, cmd, etc.), Windows must have
the proper association for that file type.

From windows explorer, double-click on the .py file. When it pops up
with, "What should I open this with?" select the the proper python
executable, and you are home free.

- Josiah
 
Reply With Quote
 
Scott David Daniels
Guest
Posts: n/a
 
      02-20-2004
Ian Pellew wrote:

> How do I get line one to call python:-
> This is line one in my python script
> #!C:/Program Files/Python2.3.3/python.exe


As Josiah Carlson pointed out, the mechanism on windows is
different. You can figure out how to do this in the command
line environment by typing "HELP ASSOC" and "HELP FTYPE".
Essentially, there is a two-layer association between file
extensions and programs. ASSOC sets the association of an
extension with a file type. FTYPE associates a file type
with a command.

So, after typing the following to your command processor:

ASSOC .py=Python.File
FTYPE Python.File=C:\python23\python.exe %1 %*

You should be able to run python files by simply typing their
name (assuming a standard python 2.3 install on drive C).

--
-Scott David Daniels

 
Reply With Quote
 
Josiah Carlson
Guest
Posts: n/a
 
      02-21-2004
> So, after typing the following to your command processor:
>
> ASSOC .py=Python.File
> FTYPE Python.File=C:\python23\python.exe %1 %*
>
> You should be able to run python files by simply typing their
> name (assuming a standard python 2.3 install on drive C).
>


I didn't know about those commands. Talk about useful.

- Josiah
 
Reply With Quote
 
Joe Mason
Guest
Posts: n/a
 
      02-21-2004
Is anyone else reading the title of this thread as a curse?

Joe
 
Reply With Quote
 
Josiah Carlson
Guest
Posts: n/a
 
      02-21-2004
> Is anyone else reading the title of this thread as a curse?

No, but I am reading it as "pound-bang" or "hash-bang".

- Josiah
 
Reply With Quote
 
Jeff Epler
Guest
Posts: n/a
 
      02-21-2004
On Sat, Feb 21, 2004 at 05:09:23PM +0000, Joe Mason wrote:
> Is anyone else reading the title of this thread as a curse?


some folks call #!... the "shebang line" of a shell script, but maybe
that falls afoul of content filters...

jeff

 
Reply With Quote
 
juergen perlinger
Guest
Posts: n/a
 
      02-23-2004

"Joe Mason" <> wrote in message
news:...
> Is anyone else reading the title of this thread as a curse?
>
> Joe


didn't until that question...


 
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
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57