[Pythonmac-SIG] Newbie Q: ARGV
Just van Rossum
just@letterror.com
Sun, 11 Jun 2000 09:35:27 +0100
At 10:23 PM -0400 10-06-2000, John Martin wrote:
>I know this is a stupid q, but I've hit run out of thoughts. I have a
>script called fred.py that in DOS/Unix expects to be run by typing:
>
>% python fred.py filename
>
>How do I run this on Mac? Should I be able to just open the IDE and type:
>
>>>>fred.py filename
No.
>or
>
>>>>fred filename
No...
>? Neither one works.
That's because the Python interactive prompt is no replacement for a
command line.
MacOS (before MacOSX) doesn't have a command line, so you can't do this
directly.
However, you have a couple of options, but none work in the IDE:
1) Drop the script on PythonInterpreter, and press the option key as soon
as you release the mouse button. Click the button "Set unix-style command
line...". Enter your options here, without the name of the script.
2) If all argv needs is a filename (or multiple file names), you can create
an applet for your script by dropping it on BuildApplet. Applets do some
argv emulation: files (or folders) dropped on the applet appear in
sys.argv[1:] (sys.argv[0] being the name of the script, as under unix/dos.)
Just