[Tutor] How can I make my script work without calling Python?
alan.gauld@bt.com
alan.gauld@bt.com
Fri, 30 Mar 2001 10:57:37 +0100
------_=_NextPart_001_01C0B8FF.D9A90D40
Content-type: text/plain; charset="iso-8859-1"
I have quick question. let's say I have a script (foo.py) which takes some
parameters (x,y,z). the usual way to run is to type:
>python foo.py x y z
Is there anyway I can make it work without calling Python i.e
>foo.py x y z
Sure just call it.
for example if I create a file:
C:\args.py that looks like:
import sys
for arg in sys.argv: print arg
print 'Thats it'
raw_input("Hit enter to exit")
And bring up the run dalog from Start|Run
I can type: c:\args.py 1 2 3
And get
C:\args.py
1
2
3
Hit enter to exit
All you need is Python in your PATH and the .py file extension associated
with
python.exe - both of which is done by the windoze installer.
Just do it...
Alan g.
------_=_NextPart_001_01C0B8FF.D9A90D40
Content-type: text/html; charset="iso-8859-1"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 5.00.3013.2600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<BLOCKQUOTE
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
<DIV><FONT face=Arial size=2>I have quick question. let's say I have a script
(foo.py) which takes some parameters (x,y,z). the usual way to run is to
type:</FONT></DIV>
<DIV><FONT face=Arial size=2>>python foo.py x y z</FONT></DIV>
<DIV><FONT face=Arial size=2>Is there anyway I can make it work without
calling Python i.e</FONT></DIV>
<DIV><FONT face=Arial size=2>>foo.py x y z </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV> </DIV></BLOCKQUOTE>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=380465709-30032001>Sure
just call it.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=380465709-30032001>for
example if I create a file:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001>C:\args.py that looks like:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=380465709-30032001>import
sys</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=380465709-30032001>for
arg in sys.argv: print arg</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=380465709-30032001>print
'Thats it'</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001>raw_input("Hit enter to exit")</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=380465709-30032001>And
bring up the run dalog from Start|Run</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=380465709-30032001>I can
type: c:\args.py 1 2 3</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=380465709-30032001>And
get</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001>C:\args.py</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001>1</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001>2</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001>3</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=380465709-30032001>Hit
enter to exit</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=380465709-30032001>All
you need is Python in your PATH and the .py file extension associated with
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001>python.exe - both of which is done by the windoze
installer.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=380465709-30032001>Just
do it...</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN
class=380465709-30032001></SPAN></FONT> </DIV>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=380465709-30032001>Alan
g.</SPAN></FONT></DIV></BODY></HTML>
------_=_NextPart_001_01C0B8FF.D9A90D40--