sys.argv is a list of all arguments from the command line. However,
you'll rarely deal with it directly, there's various modules that deal
with handling arguments. I believe the current one is argparse: http://docs.python.org/library/argparse.html#module-argparse
$hg commit "This is a commit name"
['C:\\hg.py', 'commit', 'This is a commit name']
Chapel Hill NC
In message <mailman.501.1283789339.29448.python-list*******>, Hugo Arts
Interesting that Python didnâ€™t bother to mimic the underlying POSIX
convention of passing the command line as arguments to the mainline routine.
I always felt it was more useful to have command arguments directly
accessible as globals, rather than having to pass them from the mainline.
There *is* no mainline routine in Python.
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
What "mainline routine"... The only programming language(s) I've
ever used that requires there be something called "main" in order to
start a program is the C/C++ family.
FORTRAN just differentiates by having the main file start with
whereas subfiles are all either (or both)
My college COBOL never used multifile assignments, so I'm not sure
if there was a difference between main and linked modules.
Ada -- defined by the body file used to start the build sequence...
Original Pascal did not make use of linkable subfiles, and the only
defined "arguments" on the main procedure were the logical names of I/O
None of them have command line arguments "passed" in to some
starting point -- all had to use some runtime library function to ask
for the command line contents.
Wulfraed Dennis Lee Bieber AF6VN
What mainline routine?
That's why we have namespaces. If you need the command line arguments,
you just import sys and you have access to them.
In message <mailman.599.1284008342.29448.python-list*******>, Dennis Lee
Itâ€™s always a language-specific routine, since at the underlying POSIX level
(exposed by C), the command line is passed as arguments to the mainline
Java uses a method defined as "public static void main(String args)"
There isn't, but command line argument passing is implementation-
dependent and is complicated by the ability to define callable sub-
programs in the same source file as the main program. The most general
method is to use ACCEPT statements. MicroFocus COBOL uses "ACCEPT ...
FROM ARGUMENT-NUMBER", AIX COBOL uses a special system call and ICL 2900
COBOL and IBM COBOL/400, where the command line uses function call
notation, map the command line arguments into a LINKAGE SECTION.
In short: this area of COBOL is a mess.
PL/I specifies the main procedure with an OPTIONS(MAIN) clause and
declares the integer ARGC_ and pointer ARGV_ variables in it, which are
used like their C equivalents.
martin@ | Martin Gregorie
gregorie. | Essex, UK
[ ... ]
Historical COBOL had a PROCEDURE DIVISION which marked the start of
execution. But historical COBOL didn't pass parameters anyway. You read
your optional arguments from a file, or accepted a few from an input device.
I don't know PL/I generally, but with Multics PL/I any externally accessible
procedure could be called from the command line:
any_program$ea_proc a b c
passing (for example) 'a', 'b', and 'c' as parameters. If the parameters
were declared as variable-length character strings:
ea_proc: proc (x, y, z);
dcl (x, y, z) char (*);
this would even work. Illustrating that the command-line-parameter-passing
question is a deal with the operating system at least as much as it's a
language issue. Posix aren't the only O/S.
I think you mean COMMON.
I think it could also read from switches. As in front-panel on/off switches.
i meant BLOCKDATA
It exists but I've only seen it used once... And I don't recall it
being "executable" in the same way as program/function/subroutine.
Wulfraed Dennis Lee Bieber AF6VN
BLOCKDATA is an initializer. The actual storage is allocated by COMMON.
i simply meant that the BLOCKDATA statement can begin a subfile as
well as SUBROUTINE or FUNCTION
Sarò un'ingenua ma continuo a pensarla come prima, anche se
probabilmente i fatti mi smentiscono. -- Francy, in IHC