command line arguments?

Fredrik Lundh fredrik at pythonware.com
Wed Aug 14 19:59:38 CEST 2002


brobbins333 at shaw.ca wrote:

> Is it possible to invoke a Python script with command line arguments
> in the manner of C?
>
> Something like this (not in the interactive interpreter):
>
> C:\> python myscript.py arg1 arg2

the script name and the arguments end up in a list called
sys.argv.  in your case, the list would contain:

    ["myscript.py", "arg1", "arg2"]

see section 2.1.1 in the tutorial:

    http://www.python.org/doc/current/tut/node4.html

</F>





More information about the Python-list mailing list