[Tutor] Arguments from the command line

Mel mwilson at the-wire.com
Thu Sep 9 10:23:03 EDT 2010


Dennis Lee Bieber wrote:

> On Thu, 09 Sep 2010 12:38:04 +1200, Lawrence D'Oliveiro
> <ldo at geek-central.gen.new_zealand> declaimed the following in
> gmane.comp.python.general:
> 
>> In message <mailman.501.1283789339.29448.python-list at python.org>, Hugo
>> Arts wrote:
>> 
>> > sys.argv is a list of all arguments from the command line ...
>> 
>> Interesting that Python didn’t bother to mimic the underlying POSIX
>> convention of passing the command line as arguments to the mainline
>> routine.
>>
> 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.
[ ... ]
> My college COBOL never used multifile assignments, so I'm not sure
> if there was a difference between main and linked modules.

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.

	Mel.




More information about the Python-list mailing list