[Tutor] Arguments from the command line

Steven D'Aprano steve at pearwood.info
Tue Sep 7 00:48:27 CEST 2010


On Tue, 7 Sep 2010 02:08:27 am Hugo Arts wrote:

> sys.argv is a list of all arguments from the command line. However,
> you'll rarely deal with it directly, there's various modules that
> deal with handling arguments. I believe the current one is argparse:
> http://docs.python.org/library/argparse.html#module-argparse

In my experience, getopt is a gentler introduction to argument parsing, 
because it does much less :)

optparse is another good one.

All three are available up to Python 2.7, and possibly in 3.1 as well, I 
haven't checked.


-- 
Steven D'Aprano


More information about the Tutor mailing list