[Tutor] Arguments from the command line
Martin Gregorie
martin at address-in-sig.invalid
Thu Sep 9 06:12:44 EDT 2010
On Wed, 08 Sep 2010 21:58:49 -0700, 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.
>
Java uses a method defined as "public static void main(String[] args)"
> My college COBOL never used multifile assignments, so I'm not sure
> if there was a difference between main and linked modules.
>
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
org |
More information about the Python-list
mailing list