How do I send arguments to a function by using windows command prompt?

You can play with this ...

# test Python command line arguments

import sys

if (len(sys.argv) >= 2):
    # skip sys.argv[0]
    commandline_args = sys.argv[1:] 
    print( commandline_args ) 
raw_input("Press Enter to go on ...")  # wait

"""my output for args  1 2 3  -->
['1', '2', '3']

How do I call the program from the command line?

Type your python command (*if you haven't set it up you'll need to use the full pathname to python.exe or pythonw.exe), then the name of your script, then the command line arguments... here's an example:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.


C:\>C:\Python26\python.exe these are command line args


Note: The simply contained the following:

import sys
print sys.argv

In my environment I've set the "python" command to point to "C:\Python26\python.exe", that way when I'm in the cmd line I can just type "python <script_name> [args]"... it's much faster.

This question has already been answered. Start a new discussion instead.