Website hosting service by Active-Venture.com
  

 Back to Index


6.20.2.2 Other store_* actions

Flag options--set a variable to true or false when a particular option is seen--are quite common. optparse supports them with two separate actions, ``store_true'' and ``store_false''. For example, you might have a verbose flag that is turned on with -v and off with -q:

 

parser.add_option("-v", action="store_true", dest="verbose")
parser.add_option("-q", action="store_false", dest="verbose")

Here we have two different options with the same destination, which is perfectly OK. (It just means you have to be a bit careful when setting default values--see below.)

When optparse sees -v on the command line, it sets options.verbose to True; when it sees -q, it sets options.verbose to False.

 

  

 

© 2002-2004 Active-Venture.com Webhosting Service

 

Disclaimer: This documentation is provided only for the benefits of our hosting customers.
For authoritative source of the documentation, please refer to http://python.org/doc/

 

Active-Domain.com offers domain name registration, domain name transfer and domain search services  

Cheap domain registration : Register domain name or buy domain name, including free domain hosting services

 
 

Domain registration : Buy domain name or register domain name from $5.95/year only