arguments from the prompt

Alex alex at somewhere.round.here
Sun Feb 6 17:51:57 EST 2000


> how do I write a python script to recive arguments from the command
> prompt?

This should get you started:

#!/usr/bin/python
# Or whatever the path for the python executable is.

from sys import argv
import pprint

pprint.pprint (sys.argv)
######################################################################

Then, the command line,

puf% cd python/fun/
puf% chmod u+x command_line_args.py 
puf% ./command_line_args.py These are the arguments.
['./command_line_args.py', 'These', 'are', 'the', 'arguments.']
puf% 

Here, command_line_args.py is the file the script above is in.

You might also want to check out the getopt module.

Alex.



More information about the Python-list mailing list