Command Line Argument Retrieval

ARGS is a Python script which demonstrates the retrieval of command line arguments.

This shows how a program can count and retrieve the individual command line arguments with which it was invoked. Thus, if our executable is called fu and we invoke it with the command

        fu man chu
then our argument counter will return the value 3, and the arguments, indexed by 0, 1 or 2, will return the values fu, man or chu.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


ARGS is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Source Code:

function_args shows how a function can be declared to have an arbitrary number of arguments, and how those arguments can be counted and printed at run time:

You can go up one level to the PYTHON source codes.

Last revised on 01 January 2011.